@matheusbsbs / matheus-bagliano / commits / 9c5665aa3c
Fork 0

Allow HTTP proxy to be overridden in config

The http_proxy / HTTPS_PROXY variables used by curl to control proxying may not be suitable for git. Allow the user to override them in the configuration file. Signed-off-by: Junio C Hamano <gitster@pobox.com>

Sam Vilain committed Nov 23, 2007 at 13:07 UTC 9c5665aa3c938b0e085ca34a8126110edcffa217
2 files changed +15
Documentation/config.txt
+4
@@ -550,6 +550,10 @@ specified as 'gitcvs.<access_method>.<varname>' (where 'access_method'
550 is one of "ext" and "pserver") to make them apply only for the given
551 access method.
552
553 +http.proxy::
554 + Override the HTTP proxy, normally configured using the 'http_proxy'
555 + environment variable (see gitlink:curl[1]).
556 +
557 http.sslVerify::
558 Whether to verify the SSL certificate when fetching or pushing
559 over HTTPS. Can be overridden by the 'GIT_SSL_NO_VERIFY' environment
http.c
+11
@@ -24,6 +24,7 @@ char *ssl_cainfo = NULL;
24 long curl_low_speed_limit = -1;
25 long curl_low_speed_time = -1;
26 int curl_ftp_no_epsv = 0;
27 +char *curl_http_proxy = NULL;
28
29 struct curl_slist *pragma_header;
30
@@ -160,6 +161,13 @@ static int http_options(const char *var, const char *value)
161 curl_ftp_no_epsv = git_config_bool(var, value);
162 return 0;
163 }
164 + if (!strcmp("http.proxy", var)) {
165 + if (curl_http_proxy == NULL) {
166 + curl_http_proxy = xmalloc(strlen(value)+1);
167 + strcpy(curl_http_proxy, value);
168 + }
169 + return 0;
170 + }
171
172 /* Fall back on the default ones */
173 return git_default_config(var, value);
@@ -205,6 +213,9 @@ static CURL* get_curl_handle(void)
213 if (curl_ftp_no_epsv)
214 curl_easy_setopt(result, CURLOPT_FTP_USE_EPSV, 0);
215
216 + if (curl_http_proxy)
217 + curl_easy_setopt(result, CURLOPT_PROXY, curl_http_proxy);
218 +
219 return result;
220 }
221