From 14c98218845ad2acbd42b8d913503ff6fb3fd2ac Mon Sep 17 00:00:00 2001 From: Sam Vilain Date: Tue, 4 Dec 2007 10:48:54 +1300 Subject: [PATCH] Add remote..proxy As well as allowing a default http.proxy option, allow it to be set per-remote. Signed-off-by: Sam Vilain Signed-off-by: Junio C Hamano --- Documentation/config.txt | 8 +++++++- remote.c | 2 ++ remote.h | 5 +++++ transport.c | 4 ++++ 4 files changed, 18 insertions(+), 1 deletion(-) diff --git a/Documentation/config.txt b/Documentation/config.txt index 15745de67..6ae11842e 100644 --- a/Documentation/config.txt +++ b/Documentation/config.txt @@ -552,7 +552,8 @@ access method. http.proxy:: Override the HTTP proxy, normally configured using the 'http_proxy' - environment variable (see gitlink:curl[1]). + environment variable (see gitlink:curl[1]). This can be overridden + on a per-remote basis; see remote..proxy http.sslVerify:: Whether to verify the SSL certificate when fetching or pushing @@ -702,6 +703,11 @@ remote..url:: The URL of a remote repository. See gitlink:git-fetch[1] or gitlink:git-push[1]. +remote..proxy:: + For remotes that require curl (http, https and ftp), the URL to + the proxy to use for that remote. Set to the empty string to + disable proxying for that remote. + remote..fetch:: The default set of "refspec" for gitlink:git-fetch[1]. See gitlink:git-fetch[1]. diff --git a/remote.c b/remote.c index bb0105908..46e5f0424 100644 --- a/remote.c +++ b/remote.c @@ -278,6 +278,8 @@ static int handle_config(const char *key, const char *value) } else if (!strcmp(subkey, ".tagopt")) { if (!strcmp(value, "--no-tags")) remote->fetch_tags = -1; + } else if (!strcmp(subkey, ".proxy")) { + remote->http_proxy = xstrdup(value); } return 0; } diff --git a/remote.h b/remote.h index b10036cae..86e036d61 100644 --- a/remote.h +++ b/remote.h @@ -25,6 +25,11 @@ struct remote { const char *receivepack; const char *uploadpack; + + /* + * for curl remotes only + */ + char *http_proxy; }; struct remote *remote_get(const char *name); diff --git a/transport.c b/transport.c index 50db9807d..3eb93b487 100644 --- a/transport.c +++ b/transport.c @@ -470,6 +470,10 @@ static struct ref *get_refs_via_curl(struct transport *transport) curl_easy_setopt(slot->curl, CURLOPT_WRITEFUNCTION, fwrite_buffer); curl_easy_setopt(slot->curl, CURLOPT_URL, refs_url); curl_easy_setopt(slot->curl, CURLOPT_HTTPHEADER, NULL); + if (transport->remote->http_proxy) + curl_easy_setopt(slot->curl, CURLOPT_PROXY, + transport->remote->http_proxy); + if (start_active_slot(slot)) { run_active_slot(slot); if (results.curl_result != CURLE_OK) { -- 2.30.2