{"thread":{"id":"10985","subject":"[PATCH] Allow HTTP proxy to be overridden in config","startedAt":"2007-11-23T00:07:00Z","lastAt":"2007-12-04T09:22:46Z","messageCount":9,"participants":["Sam Vilain","Junio C Hamano","Andreas Ericsson","Johannes Schindelin"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"60721","messageId":"1195776420-22075-1-git-send-email-sam.vilain@catalyst.net.nz","threadId":"10985","inReplyTo":null,"subject":"[PATCH] Allow HTTP proxy to be overridden in config","fromName":"Sam Vilain","fromEmail":"sam.vilain@catalyst.net.nz","sentAt":"2007-11-23T00:07:00Z","receivedAt":"2007-11-23T00:07:00Z","isPatch":true,"sender":{"key":"sam@vilain.net","avatar":"https://gravatar.com/avatar/8fc840ca854dbf6f7065b4335e3b934951c1dca3b11db688e95e471901f8f4a8?d=mp&s=160"},"body":"The http_proxy / HTTPS_PROXY variables used by curl to control\nproxying may not be suitable for git.  Allow the user to override them\nin the configuration file.\n---\n  In particular, privoxy will block directories called /ad/ ... d'oh!\n\n Documentation/config.txt |    4 ++++\n http.c                   |   11 +++++++++++\n 2 files changed, 15 insertions(+), 0 deletions(-)\n\ndiff --git a/Documentation/config.txt b/Documentation/config.txt\nindex 7ee97df..859a7f3 100644\n--- a/Documentation/config.txt\n+++ b/Documentation/config.txt\n@@ -515,6 +515,10 @@ specified as 'gitcvs.<access_method>.<varname>' (where 'access_method'\n is one of \"ext\" and \"pserver\") to make them apply only for the given\n access method.\n \n+http.proxy::\n+\tOverride the HTTP proxy, normally configured using the 'http_proxy'\n+\tenvironment variable (see gitlink:curl[1]).\n+\n http.sslVerify::\n \tWhether to verify the SSL certificate when fetching or pushing\n \tover HTTPS. Can be overridden by the 'GIT_SSL_NO_VERIFY' environment\ndiff --git a/http.c b/http.c\nindex c6fb8ac..8f60d89 100644\n--- a/http.c\n+++ b/http.c\n@@ -24,6 +24,7 @@ char *ssl_cainfo = NULL;\n long curl_low_speed_limit = -1;\n long curl_low_speed_time = -1;\n int curl_ftp_no_epsv = 0;\n+char *curl_http_proxy = NULL;\n \n struct curl_slist *pragma_header;\n \n@@ -160,6 +161,13 @@ static int http_options(const char *var, const char *value)\n \t\tcurl_ftp_no_epsv = git_config_bool(var, value);\n \t\treturn 0;\n \t}\n+\tif (!strcmp(\"http.proxy\", var)) {\n+\t\tif (curl_http_proxy == NULL) {\n+\t\t\tcurl_http_proxy = xmalloc(strlen(value)+1);\n+\t\t\tstrcpy(curl_http_proxy, value);\n+\t\t}\n+\t\treturn 0;\n+\t}\n \n \t/* Fall back on the default ones */\n \treturn git_default_config(var, value);\n@@ -205,6 +213,9 @@ static CURL* get_curl_handle(void)\n \tif (curl_ftp_no_epsv)\n \t\tcurl_easy_setopt(result, CURLOPT_FTP_USE_EPSV, 0);\n \n+\tif (curl_http_proxy)\n+\t\tcurl_easy_setopt(result, CURLOPT_PROXY, curl_http_proxy);\n+\n \treturn result;\n }\n \n-- \n1.5.3.5\n"},{"id":"60723","messageId":"7voddl24b7.fsf@gitster.siamese.dyndns.org","threadId":"10985","inReplyTo":"1195776420-22075-1-git-send-email-sam.vilain@catalyst.net.nz","subject":"Re: [PATCH] Allow HTTP proxy to be overridden in config","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2007-11-23T00:28:28Z","receivedAt":"2007-11-23T00:28:28Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Sam Vilain <sam.vilain@catalyst.net.nz> writes:\n\n> The http_proxy / HTTPS_PROXY variables used by curl to control\n> proxying may not be suitable for git.  Allow the user to override them\n> in the configuration file.\n> ---\n>   In particular, privoxy will block directories called /ad/ ... d'oh!\n\n> diff --git a/Documentation/config.txt b/Documentation/config.txt\n> index 7ee97df..859a7f3 100644\n> --- a/Documentation/config.txt\n> +++ b/Documentation/config.txt\n> @@ -515,6 +515,10 @@ specified as 'gitcvs.<access_method>.<varname>' (where 'access_method'\n>  is one of \"ext\" and \"pserver\") to make them apply only for the given\n>  access method.\n>  \n> +http.proxy::\n> +\tOverride the HTTP proxy, normally configured using the 'http_proxy'\n> +\tenvironment variable (see gitlink:curl[1]).\n> +\n\nThis may work around the issue you cited, but it makes me wonder\nif it is a road to insanity.  Does the curl library expect that\n(1) each and every HTTP talking application that uses the\nlibrary offer this kind of knob for its users to tweak, and (2)\nusers set the knob for each and every one of such application?\n\nI would say if privoxy cannot be tweaked to allow /ad/ in chosen\ncontext (e.g. /ad/ in general is rejected but /objects/ad/ is\nOk), that is what needs to be fixed.\n\nOr it would be the use of such a broken proxy by the user.  That\ncan be fixed and much easily.\n"},{"id":"60733","messageId":"47464A90.4030509@catalyst.net.nz","threadId":"10985","inReplyTo":"7voddl24b7.fsf@gitster.siamese.dyndns.org","subject":"Re: [PATCH] Allow HTTP proxy to be overridden in config","fromName":"Sam Vilain","fromEmail":"sam.vilain@catalyst.net.nz","sentAt":"2007-11-23T03:35:44Z","receivedAt":"2007-11-23T03:35:44Z","isPatch":true,"sender":{"key":"sam@vilain.net","avatar":"https://gravatar.com/avatar/8fc840ca854dbf6f7065b4335e3b934951c1dca3b11db688e95e471901f8f4a8?d=mp&s=160"},"body":"Junio C Hamano wrote:\n>> The http_proxy / HTTPS_PROXY variables used by curl to control\n>> proxying may not be suitable for git.  Allow the user to override them\n>> in the configuration file.\n>> ---\n>>   In particular, privoxy will block directories called /ad/ ... d'oh!\n>> +++ b/Documentation/config.txt\n>> +http.proxy::\n>> +\tOverride the HTTP proxy, normally configured using the 'http_proxy'\n>> +\tenvironment variable (see gitlink:curl[1]).\n> \n> This may work around the issue you cited, but it makes me wonder\n> if it is a road to insanity.  Does the curl library expect that\n> (1) each and every HTTP talking application that uses the\n> library offer this kind of knob for its users to tweak, and (2)\n> users set the knob for each and every one of such application?\n\nThis is true.  However I still think that it is a useful feature for\nmany users, with few side effects.  If nothing else the bit on the man\npage will prompt them to think, \"oh, I should set that in the environment\".\n\n> I would say if privoxy cannot be tweaked to allow /ad/ in chosen\n> context (e.g. /ad/ in general is rejected but /objects/ad/ is\n> Ok), that is what needs to be fixed.\n> Or it would be the use of such a broken proxy by the user.  That\n> can be fixed and much easily.\n\nYes - but consider the dilemma of the user.  They've apt-get installed\nthis privoxy thing and figured out how to set their applications to use\nit.  Now, it doesn't work and they think it is the proxy in the way, and\nthey've no idea that they might be able to reconfigure it.  This way\nthey can tell git to bypass it.\n\nI don't know, I see your point and pretty much agree with it.  It just\nseems like something that might come in handy (as well as be another\nvector for something you need to check when you get HTTP fetch issues -\nso maybe a command-line option would be better).\n\nActually something that would really have helped is more documentation\nof the various GIT_CURL_* environment variables available for debugging.\n-- \nSam Vilain, Chief Yak Shaver, Catalyst IT (NZ) Ltd.\nphone: +64 4 499 2267        PGP ID: 0x66B25843\n"},{"id":"61550","messageId":"7vhcj387jh.fsf@gitster.siamese.dyndns.org","threadId":"10985","inReplyTo":"47464A90.4030509@catalyst.net.nz","subject":"Re: [PATCH] Allow HTTP proxy to be overridden in config","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2007-12-01T02:37:06Z","receivedAt":"2007-12-01T02:37:06Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Sam Vilain <sam.vilain@catalyst.net.nz> writes:\n\n> Junio C Hamano wrote:\n>>> The http_proxy / HTTPS_PROXY variables used by curl to control\n>>> proxying may not be suitable for git.  Allow the user to override them\n>>> in the configuration file.\n>>> ---\n>>>   In particular, privoxy will block directories called /ad/ ... d'oh!\n>>> +++ b/Documentation/config.txt\n>>> +http.proxy::\n>>> +\tOverride the HTTP proxy, normally configured using the 'http_proxy'\n>>> +\tenvironment variable (see gitlink:curl[1]).\n>> \n>> This may work around the issue you cited, but it makes me wonder\n>> if it is a road to insanity.  Does the curl library expect that\n>> (1) each and every HTTP talking application that uses the\n>> library offer this kind of knob for its users to tweak, and (2)\n>> users set the knob for each and every one of such application?\n>\n> This is true.  However I still think that it is a useful feature for\n> many users, with few side effects.  If nothing else the bit on the man\n> page will prompt them to think, \"oh, I should set that in the environment\".\n>\n>> I would say if privoxy cannot be tweaked to allow /ad/ in chosen\n>> context (e.g. /ad/ in general is rejected but /objects/ad/ is\n>> Ok), that is what needs to be fixed.\n>> Or it would be the use of such a broken proxy by the user.  That\n>> can be fixed and much easily.\n>\n> Yes - but consider the dilemma of the user.  They've apt-get installed\n> this privoxy thing and figured out how to set their applications to use\n> it.  Now, it doesn't work and they think it is the proxy in the way, and\n> they've no idea that they might be able to reconfigure it.  This way\n> they can tell git to bypass it.\n>\n> I don't know, I see your point and pretty much agree with it.  It just\n> seems like something that might come in handy (as well as be another\n> vector for something you need to check when you get HTTP fetch issues -\n> so maybe a command-line option would be better).\n>\n> Actually something that would really have helped is more documentation\n> of the various GIT_CURL_* environment variables available for debugging.\n\nHaving thought about this a bit more, I changed my mind.  From the\nbeginning, I did not mind adding a dozen or so lines if the change helps\nthe user.  I was not _fundamentally_ opposed to your patch.\n\nHowever.\n\nThere may be other environment variables that the users may want to set\ndifferently when running git from the settings they use in their\ninteractive sessions.  We have precedentsto support such situations in\nthe form of git-specific environment variables (e.g. GIT_EDITOR and\nGIT_PAGER).  These might have been a road to insanity already, and what\nwe should have done may be to introduce multivalued core.environment\nvariables in $HOME/.gitconfig, like so:\n\n\t[core.environment]\n        \tEDITOR = vim\n\t\tPAGER = less\n\nwithout introducing GIT_foo environment variables.  We can then change\nthe git potty[*1*] start-up sequence to add them to the enviornment.  But\nthis is a bit like water under the bridge now.\n\nWhile that approach could work for environment variables that apply\nglobally to any and all git sessions the user may run, I suspect it\nwould not work well for things like http_proxy.  If we really wanted to\nhelp users, I think it should be tied to which remote we are going to,\njust like we made git-send-email to use different mailpath depending on\nwhich project you are communicating with.\n\nIn that sense, I think http.proxy configuration variable does not go far\nenough, even though it might be a step in the right direction.  Perhaps\nuse your configuration variable http.proxy (or \"core.environment\") to\ndefine the global default, with remote.$name.httpproxy to override it?\n\n\n[Footnote]\n\n*1* git(7) calls \"git\" itself as \"git potty\".  Is this word still used?\nI also notice that Andreas's name is misspelled there.\n"},{"id":"61754","messageId":"4753C7AD.3000406@op5.se","threadId":"10985","inReplyTo":"7vhcj387jh.fsf@gitster.siamese.dyndns.org","subject":"Re: [PATCH] Allow HTTP proxy to be overridden in config","fromName":"Andreas Ericsson","fromEmail":"ae@op5.se","sentAt":"2007-12-03T09:09:01Z","receivedAt":"2007-12-03T09:09:01Z","isPatch":true,"sender":{"key":"ae@op5.se","avatar":"https://gravatar.com/avatar/426e89595c75a8f5252dd0c989e5fabe5bcac616e68557427ad9aef6b0ca342a?d=mp&s=160"},"body":"Junio C Hamano wrote:\n> \n> [Footnote]\n> \n> *1* git(7) calls \"git\" itself as \"git potty\".  Is this word still used?\n> I also notice that Andreas's name is misspelled there.\n\n\nAFAIR I sort of invented that to disambiguate git-the-program from\ngit-the-project while working on writing the program in C. I haven't\nheard/seen it a lot since then, except on a few occasions where it\nhelped serve that same purpose.\n\nI also misspelled my own name in that patch. Perhaps it's time I\ncorrected that.\n\n---%<---%<---%<---\nFrom: Andreas Ericsson <ae@op5.se>\nSubject: [PATCH] Correct typo in Documentation/git.txt\n\nSigned-off-by: Andreas Ericsson <ae@op5.se>\n---\n\ndiff --git a/Documentation/git.txt b/Documentation/git.txt\nindex 9ff4659..6c98ab2 100644\n--- a/Documentation/git.txt\n+++ b/Documentation/git.txt\n@@ -536,7 +536,7 @@ Authors\n -------\n * git's founding father is Linus Torvalds <torvalds@osdl.org>.\n * The current git nurse is Junio C Hamano <gitster@pobox.com>.\n-* The git potty was written by Andres Ericsson <ae@op5.se>.\n+* The git potty was written by Andreas Ericsson <ae@op5.se>.\n * General upbringing is handled by the git-list <git@vger.kernel.org>.\n \n Documentation\n---%<---%<---%<---\n-- \nAndreas Ericsson                   andreas.ericsson@op5.se\nOP5 AB                             www.op5.se\nTel: +46 8-230225                  Fax: +46 8-230231\n"},{"id":"61772","messageId":"Pine.LNX.4.64.0712031113030.27959@racer.site","threadId":"10985","inReplyTo":"4753C7AD.3000406@op5.se","subject":"Re: [PATCH] Allow HTTP proxy to be overridden in config","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2007-12-03T11:13:24Z","receivedAt":"2007-12-03T11:13:24Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Mon, 3 Dec 2007, Andreas Ericsson wrote:\n\n> Junio C Hamano wrote:\n> > \n> > [Footnote]\n> > \n> > *1* git(7) calls \"git\" itself as \"git potty\".  Is this word still used?\n> > I also notice that Andreas's name is misspelled there.\n> \n> \n> AFAIR I sort of invented that to disambiguate git-the-program from \n> git-the-project while working on writing the program in C. I haven't \n> heard/seen it a lot since then, except on a few occasions where it \n> helped serve that same purpose.\n\nI always spell it \"git wrapper\".\n\nCiao,\nDscho\n"},{"id":"61827","messageId":"475479C6.3050506@catalyst.net.nz","threadId":"10985","inReplyTo":"7vhcj387jh.fsf@gitster.siamese.dyndns.org","subject":"Re: [PATCH] Allow HTTP proxy to be overridden in config","fromName":"Sam Vilain","fromEmail":"sam.vilain@catalyst.net.nz","sentAt":"2007-12-03T21:48:54Z","receivedAt":"2007-12-03T21:48:54Z","isPatch":true,"sender":{"key":"sam@vilain.net","avatar":"https://gravatar.com/avatar/8fc840ca854dbf6f7065b4335e3b934951c1dca3b11db688e95e471901f8f4a8?d=mp&s=160"},"body":"Junio C Hamano wrote:\n> In that sense, I think http.proxy configuration variable does not go far\n> enough, even though it might be a step in the right direction.  Perhaps\n> use your configuration variable http.proxy (or \"core.environment\") to\n> define the global default, with remote.$name.httpproxy to override it?\n\nSure, why not.\n\nSubject: [PATCH] Add remote.<name>.proxy\n\nAs well as allowing a default proxy option, allow it to be set\nper-remote.\n\nSigned-off-by: Sam Vilain <sam.vilain@catalyst.net.nz>\n---\n Documentation/config.txt |    8 +++++++-\n remote.c                 |    2 ++\n remote.h                 |    5 +++++\n transport.c              |    3 +++\n 4 files changed, 17 insertions(+), 1 deletions(-)\n\ndiff --git a/Documentation/config.txt b/Documentation/config.txt\nindex 7e6c02a..831df58 100644\n--- a/Documentation/config.txt\n+++ b/Documentation/config.txt\n@@ -545,7 +545,8 @@ access method.\n \n http.proxy::\n \tOverride the HTTP proxy, normally configured using the 'http_proxy'\n-\tenvironment variable (see gitlink:curl[1]).\n+\tenvironment variable (see gitlink:curl[1]).  This can be overridden\n+\ton a per-remote basis; see remote.<name>.proxy\n \n http.sslVerify::\n \tWhether to verify the SSL certificate when fetching or pushing\n@@ -695,6 +696,11 @@ remote.<name>.url::\n \tThe URL of a remote repository.  See gitlink:git-fetch[1] or\n \tgitlink:git-push[1].\n \n+remote.<name>.proxy::\n+\tFor remotes that require curl (http, https and ftp), the URL to\n+\tthe proxy to use for that remote.  Set to the empty string to\n+\tdisable proxying for that remote.\n+\n remote.<name>.fetch::\n \tThe default set of \"refspec\" for gitlink:git-fetch[1]. See\n \tgitlink:git-fetch[1].\ndiff --git a/remote.c b/remote.c\nindex bec2ba1..94df314 100644\n--- a/remote.c\n+++ b/remote.c\n@@ -278,6 +278,8 @@ static int handle_config(const char *key, const char *value)\n \t} else if (!strcmp(subkey, \".tagopt\")) {\n \t\tif (!strcmp(value, \"--no-tags\"))\n \t\t\tremote->fetch_tags = -1;\n+\t} else if (!strcmp(subkey, \".proxy\")) {\n+\t\tremote->fetch_refspec = xstrdup(value);\n \t}\n \treturn 0;\n }\ndiff --git a/remote.h b/remote.h\nindex 878b4ec..2268558 100644\n--- a/remote.h\n+++ b/remote.h\n@@ -25,6 +25,11 @@ struct remote {\n \n \tconst char *receivepack;\n \tconst char *uploadpack;\n+\n+\t/*\n+\t * for curl remotes only\n+\t */\n+\tconst char *proxy;\n };\n \n struct remote *remote_get(const char *name);\ndiff --git a/transport.c b/transport.c\nindex 43b9e7c..c62ec88 100644\n--- a/transport.c\n+++ b/transport.c\n@@ -463,6 +463,9 @@ static struct ref *get_refs_via_curl(const struct transport *transport)\n \tcurl_easy_setopt(slot->curl, CURLOPT_WRITEFUNCTION, fwrite_buffer);\n \tcurl_easy_setopt(slot->curl, CURLOPT_URL, refs_url);\n \tcurl_easy_setopt(slot->curl, CURLOPT_HTTPHEADER, NULL);\n+\tif (transport->remote->proxy) {\n+\t\tcurl_easy_setopt(slot->curl, CURLOPT_PROXY, transport->remote->proxy);\n+\t}\n \tif (start_active_slot(slot)) {\n \t\trun_active_slot(slot);\n \t\tif (results.curl_result != CURLE_OK) {\n-- \n1.5.3.5\n"},{"id":"61889","messageId":"7vodd66dzw.fsf@gitster.siamese.dyndns.org","threadId":"10985","inReplyTo":"475479C6.3050506@catalyst.net.nz","subject":"Re: [PATCH] Allow HTTP proxy to be overridden in config","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2007-12-04T08:49:39Z","receivedAt":"2007-12-04T08:49:39Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Sam Vilain <sam.vilain@catalyst.net.nz> writes:\n\n> Subject: [PATCH] Add remote.<name>.proxy\n>\n> As well as allowing a default proxy option, allow it to be set\n> per-remote.\n\nThanks.\n\nI was very tempted to rename them to remote.*.httpproxy, but ended up\nkeeping the name of the variable.  We might want to allow tunnelling the\ngit native transport over the named proxy when remote.*.url is native\ntransport.\n"},{"id":"61892","messageId":"47551C66.4010202@catalyst.net.nz","threadId":"10985","inReplyTo":"7vodd66dzw.fsf@gitster.siamese.dyndns.org","subject":"Re: [PATCH] Allow HTTP proxy to be overridden in config","fromName":"Sam Vilain","fromEmail":"sam.vilain@catalyst.net.nz","sentAt":"2007-12-04T09:22:46Z","receivedAt":"2007-12-04T09:22:46Z","isPatch":true,"sender":{"key":"sam@vilain.net","avatar":"https://gravatar.com/avatar/8fc840ca854dbf6f7065b4335e3b934951c1dca3b11db688e95e471901f8f4a8?d=mp&s=160"},"body":"Junio C Hamano wrote:\n>> Subject: [PATCH] Add remote.<name>.proxy\n>> As well as allowing a default proxy option, allow it to be set\n>> per-remote.\n> \n> Thanks.\n> \n> I was very tempted to rename them to remote.*.httpproxy, but ended up\n> keeping the name of the variable.  We might want to allow tunnelling the\n> git native transport over the named proxy when remote.*.url is native\n> transport.\n\nAlso, it controls proxy for all of the curl-based git transports, not\njust http.\n\nSam.\n"}]}