Skip to content

Commit

Permalink
Add remote.<name>.proxy
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Sam Vilain authored and Junio C Hamano committed Dec 4, 2007
1 parent 9c5665a commit 14c9821
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 1 deletion.
8 changes: 7 additions & 1 deletion Documentation/config.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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.<name>.proxy

http.sslVerify::
Whether to verify the SSL certificate when fetching or pushing
Expand Down Expand Up @@ -702,6 +703,11 @@ remote.<name>.url::
The URL of a remote repository. See gitlink:git-fetch[1] or
gitlink:git-push[1].

remote.<name>.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.<name>.fetch::
The default set of "refspec" for gitlink:git-fetch[1]. See
gitlink:git-fetch[1].
Expand Down
2 changes: 2 additions & 0 deletions remote.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
5 changes: 5 additions & 0 deletions remote.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 4 additions & 0 deletions transport.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 14c9821

Please sign in to comment.