From d5229e6af809a8e29c00821f27eed8fc988c947b Mon Sep 17 00:00:00 2001 From: Jesse Hathaway Date: Fri, 10 Jul 2020 15:59:09 +0000 Subject: [PATCH 1/3] FetchOptions: add ability to specify ProxyOptions Prior to this change you could not specifiy proxy options on the FetchOptions struct, which made it impossible to specify a proxy for an initial clone. This change adds the ProxyOptions to the FetchOptions struct so you can go through a proxy when cloning. --- remote.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/remote.go b/remote.go index 9d65d10..74aebe4 100644 --- a/remote.go +++ b/remote.go @@ -117,6 +117,9 @@ type FetchOptions struct { // Headers are extra headers for the fetch operation. Headers []string + + // Proxy options to use for this fetch operation + *ProxyOptions } type ProxyType uint @@ -694,6 +697,8 @@ func populateFetchOptions(options *C.git_fetch_options, opts *FetchOptions) { options.custom_headers = C.git_strarray{} options.custom_headers.count = C.size_t(len(opts.Headers)) options.custom_headers.strings = makeCStringsFromStrings(opts.Headers) + options.proxy_opts = C.git_proxy_options{} + populateProxyOptions(&options.proxy_opts, opts.ProxyOptions) } func populatePushOptions(options *C.git_push_options, opts *PushOptions) { -- 2.45.2 From db78e55d4586fabf349f8acfe7a31e01e6abfb9a Mon Sep 17 00:00:00 2001 From: Jesse Hathaway Date: Fri, 10 Jul 2020 19:33:52 +0000 Subject: [PATCH 2/3] FetchOptions: don't embed the ProxyOptions Rather than embeding the ProxyOptions struct add a member to the struct. Also use a value rather than a pointer, so that the zero value of FetchOptions is well defined. --- remote.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/remote.go b/remote.go index 74aebe4..9cfe121 100644 --- a/remote.go +++ b/remote.go @@ -119,7 +119,7 @@ type FetchOptions struct { Headers []string // Proxy options to use for this fetch operation - *ProxyOptions + ProxyOptions ProxyOptions } type ProxyType uint @@ -698,7 +698,7 @@ func populateFetchOptions(options *C.git_fetch_options, opts *FetchOptions) { options.custom_headers.count = C.size_t(len(opts.Headers)) options.custom_headers.strings = makeCStringsFromStrings(opts.Headers) options.proxy_opts = C.git_proxy_options{} - populateProxyOptions(&options.proxy_opts, opts.ProxyOptions) + populateProxyOptions(&options.proxy_opts, &opts.ProxyOptions) } func populatePushOptions(options *C.git_push_options, opts *PushOptions) { -- 2.45.2 From dea861eb424785090f04ce23a661d9252edcb26f Mon Sep 17 00:00:00 2001 From: Jesse Hathaway Date: Fri, 10 Jul 2020 19:39:34 +0000 Subject: [PATCH 3/3] populateFetchOptions: remove redundant initialization This is already preformed by git_fetch_init_options() --- remote.go | 1 - 1 file changed, 1 deletion(-) diff --git a/remote.go b/remote.go index 9cfe121..14e94a2 100644 --- a/remote.go +++ b/remote.go @@ -697,7 +697,6 @@ func populateFetchOptions(options *C.git_fetch_options, opts *FetchOptions) { options.custom_headers = C.git_strarray{} options.custom_headers.count = C.size_t(len(opts.Headers)) options.custom_headers.strings = makeCStringsFromStrings(opts.Headers) - options.proxy_opts = C.git_proxy_options{} populateProxyOptions(&options.proxy_opts, &opts.ProxyOptions) } -- 2.45.2