git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] Allow HTTP proxy to be overridden in config

From
Sam Vilain <sam.vilain@catalyst.net.nz>
Date
Dec 3, 2007, 21:48 UTC
Message-ID
<475479C6.3050506@catalyst.net.nz>
In-Reply-To
<7vhcj387jh.fsf@gitster.siamese.dyndns.org>
Junio C Hamano wrote:
> In that sense, I think http.proxy configuration variable does not go far
> enough, even though it might be a step in the right direction.  Perhaps
> use your configuration variable http.proxy (or "core.environment") to
> define the global default, with remote.$name.httpproxy to override it?
Sure, why not.
Subject: [PATCH] Add remote.<name>.proxy

As well as allowing a default proxy option, allow it to be set per-remote.

Signed-off-by: Sam Vilain <sam.vilain@catalyst.net.nz>
---
 Documentation/config.txt |    8 +++++++-
 remote.c                 |    2 ++
 remote.h                 |    5 +++++
 transport.c              |    3 +++
 4 files changed, 17 insertions(+), 1 deletions(-)
diff --git a/Documentation/config.txt b/Documentation/config.txt
index 7e6c02a..831df58 100644
--- a/Documentation/config.txt
+++ b/Documentation/config.txt
@@ -545,7 +545,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
@@ -695,6 +696,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].
diff --git a/remote.c b/remote.c
index bec2ba1..94df314 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->fetch_refspec = xstrdup(value);
 	}
 	return 0;
 }
diff --git a/remote.h b/remote.h
index 878b4ec..2268558 100644
--- a/remote.h
+++ b/remote.h
@@ -25,6 +25,11 @@ struct remote {
 
 	const char *receivepack;
 	const char *uploadpack;
+
+	/*
+	 * for curl remotes only
+	 */
+	const char *proxy;
 };
 
 struct remote *remote_get(const char *name);
diff --git a/transport.c b/transport.c
index 43b9e7c..c62ec88 100644
--- a/transport.c
+++ b/transport.c
@@ -463,6 +463,9 @@ static struct ref *get_refs_via_curl(const 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->proxy) {
+		curl_easy_setopt(slot->curl, CURLOPT_PROXY, transport->remote->proxy);
+	}
 	if (start_active_slot(slot)) {
 		run_active_slot(slot);
 		if (results.curl_result != CURLE_OK) {
-- 
1.5.3.5
Previous: Johannes SchindelinNext: Junio C Hamano
Message 7 of 9 in “Allow HTTP proxy to be overridden in config”
  1. Allow HTTP proxy to be overridden in configSam Vilain, Nov 23, 2007
  2. Junio C HamanoNov 23, 2007
  3. Sam VilainNov 23, 2007
  4. Junio C HamanoDec 1, 2007
  5. Andreas EricssonDec 3, 2007
  6. Johannes SchindelinDec 3, 2007
  7. Sam VilainDec 3, 2007
  8. Junio C HamanoDec 4, 2007
  9. Sam VilainDec 4, 2007

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.