Add remote.<name>.proxy
As well as allowing a default http.proxy option, allow it to be set per-remote. Signed-off-by: Sam Vilain <sam.vilain@catalyst.net.nz> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Sam Vilain committed
Dec 4, 2007 at 10:48 UTC
14c98218845ad2acbd42b8d913503ff6fb3fd2ac
4 files changed
+18
-1
Documentation/config.txt
+7
-1
@@ -552,7 +552,8 @@ access method.
552
553
http.proxy::
554
Override the HTTP proxy, normally configured using the 'http_proxy'
555
- environment variable (see gitlink:curl[1]).
555
+ environment variable (see gitlink:curl[1]). This can be overridden
556
+ on a per-remote basis; see remote.<name>.proxy
557
558
http.sslVerify::
559
Whether to verify the SSL certificate when fetching or pushing
@@ -702,6 +703,11 @@ remote.<name>.url::
703
The URL of a remote repository. See gitlink:git-fetch[1] or
704
gitlink:git-push[1].
705
706
+remote.<name>.proxy::
707
+ For remotes that require curl (http, https and ftp), the URL to
708
+ the proxy to use for that remote. Set to the empty string to
709
+ disable proxying for that remote.
710
+
711
remote.<name>.fetch::
712
The default set of "refspec" for gitlink:git-fetch[1]. See
713
gitlink:git-fetch[1].
remote.c
+2
@@ -278,6 +278,8 @@ static int handle_config(const char *key, const char *value)
278
} else if (!strcmp(subkey, ".tagopt")) {
279
if (!strcmp(value, "--no-tags"))
280
remote->fetch_tags = -1;
281
+ } else if (!strcmp(subkey, ".proxy")) {
282
+ remote->http_proxy = xstrdup(value);
283
}
284
return 0;
285
}
remote.h
+5
@@ -25,6 +25,11 @@ struct remote {
25
26
const char *receivepack;
27
const char *uploadpack;
28
+
29
+ /*
30
+ * for curl remotes only
31
+ */
32
+ char *http_proxy;
33
};
34
35
struct remote *remote_get(const char *name);
transport.c
+4
@@ -470,6 +470,10 @@ static struct ref *get_refs_via_curl(struct transport *transport)
470
curl_easy_setopt(slot->curl, CURLOPT_WRITEFUNCTION, fwrite_buffer);
471
curl_easy_setopt(slot->curl, CURLOPT_URL, refs_url);
472
curl_easy_setopt(slot->curl, CURLOPT_HTTPHEADER, NULL);
473
+ if (transport->remote->http_proxy)
474
+ curl_easy_setopt(slot->curl, CURLOPT_PROXY,
475
+ transport->remote->http_proxy);
476
+
477
if (start_active_slot(slot)) {
478
run_active_slot(slot);
479
if (results.curl_result != CURLE_OK) {