All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sam Vilain <sam.vilain@catalyst.net.nz>
To: Junio C Hamano <gitster@pobox.com>
Cc: git@vger.kernel.org, francois@debian.org
Subject: Re: [PATCH] Allow HTTP proxy to be overridden in config
Date: Tue, 04 Dec 2007 10:48:54 +1300	[thread overview]
Message-ID: <475479C6.3050506@catalyst.net.nz> (raw)
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

  parent reply	other threads:[~2007-12-03 22:01 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-11-23  0:07 [PATCH] Allow HTTP proxy to be overridden in config Sam Vilain
2007-11-23  0:28 ` Junio C Hamano
2007-11-23  3:35   ` Sam Vilain
2007-12-01  2:37     ` Junio C Hamano
2007-12-03  9:09       ` Andreas Ericsson
2007-12-03 11:13         ` Johannes Schindelin
2007-12-03 21:48       ` Sam Vilain [this message]
2007-12-04  8:49         ` Junio C Hamano
2007-12-04  9:22           ` Sam Vilain

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=475479C6.3050506@catalyst.net.nz \
    --to=sam.vilain@catalyst.net.nz \
    --cc=francois@debian.org \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.