From 5f3276c7e66fe54b0485da2def84a6ae322cce59 Mon Sep 17 00:00:00 2001 From: Christopher Bargren Date: Tue, 7 Feb 2017 16:33:28 -0700 Subject: [PATCH 1/3] Add support for lowercase proxy environment variables curl supports HTTPS_PROXY in addition to https_proxy (and their http counterparts). This change ensures parity with curl's behavior. --- src/remote.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/remote.c b/src/remote.c index 8da7346fb..1f5c58bd2 100644 --- a/src/remote.c +++ b/src/remote.c @@ -773,6 +773,18 @@ int git_remote__get_http_proxy(git_remote *remote, bool use_ssl, char **proxy_ur /* HTTP_PROXY / HTTPS_PROXY environment variables */ error = git__getenv(&val, use_ssl ? "HTTPS_PROXY" : "HTTP_PROXY"); + if (error < 0) { + if (error != GIT_ENOTFOUND) { + return error; + } + + giterr_clear(); + error = 0; + } + + /* try lowercase environment variables */ + error = git__getenv(&val, use_ssl ? "https_proxy" : "http_proxy"); + if (error < 0) { if (error == GIT_ENOTFOUND) { giterr_clear(); From 2af282d835662fce671cc1a6675b0b8292f05173 Mon Sep 17 00:00:00 2001 From: Christopher Bargren Date: Wed, 8 Feb 2017 15:01:30 -0700 Subject: [PATCH 2/3] Addressing PR feedback --- src/remote.c | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/src/remote.c b/src/remote.c index 1f5c58bd2..808ca78d5 100644 --- a/src/remote.c +++ b/src/remote.c @@ -770,21 +770,14 @@ int git_remote__get_http_proxy(git_remote *remote, bool use_ssl, char **proxy_ur goto found; } - /* HTTP_PROXY / HTTPS_PROXY environment variables */ - error = git__getenv(&val, use_ssl ? "HTTPS_PROXY" : "HTTP_PROXY"); - - if (error < 0) { - if (error != GIT_ENOTFOUND) { - return error; - } - - giterr_clear(); - error = 0; - } - - /* try lowercase environment variables */ + /* http_proxy / https_proxy environment variables */ error = git__getenv(&val, use_ssl ? "https_proxy" : "http_proxy"); + if (error == GIT_ENOTFOUND) { + /* try uppercase environment variables */ + error = git__getenv(&val, use_ssl ? "HTTPS_PROXY" : "HTTP_PROXY"); + } + if (error < 0) { if (error == GIT_ENOTFOUND) { giterr_clear(); From 61189a115bb347c9131224ae985fdefa073ef946 Mon Sep 17 00:00:00 2001 From: Christopher Bargren Date: Fri, 10 Feb 2017 07:59:22 -0700 Subject: [PATCH 3/3] Fixing a code style issue --- src/remote.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/remote.c b/src/remote.c index 808ca78d5..d3132f75c 100644 --- a/src/remote.c +++ b/src/remote.c @@ -773,10 +773,9 @@ int git_remote__get_http_proxy(git_remote *remote, bool use_ssl, char **proxy_ur /* http_proxy / https_proxy environment variables */ error = git__getenv(&val, use_ssl ? "https_proxy" : "http_proxy"); - if (error == GIT_ENOTFOUND) { - /* try uppercase environment variables */ + /* try uppercase environment variables */ + if (error == GIT_ENOTFOUND) error = git__getenv(&val, use_ssl ? "HTTPS_PROXY" : "HTTP_PROXY"); - } if (error < 0) { if (error == GIT_ENOTFOUND) {