summaryrefslogtreecommitdiff
path: root/src/remote.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/remote.c')
-rw-r--r--src/remote.c27
1 files changed, 18 insertions, 9 deletions
diff --git a/src/remote.c b/src/remote.c
index f31fc150a..d31e1b89e 100644
--- a/src/remote.c
+++ b/src/remote.c
@@ -153,7 +153,7 @@ static int get_check_cert(int *out, git_repository *repo)
* most specific to least specific. */
/* GIT_SSL_NO_VERIFY environment variable */
- if ((val = getenv("GIT_SSL_NO_VERIFY")) != NULL)
+ if ((val = p_getenv("GIT_SSL_NO_VERIFY")) != NULL)
return git_config_parse_bool(out, val);
/* http.sslVerify config setting */
@@ -759,7 +759,7 @@ int git_remote__get_http_proxy(git_remote *remote, bool use_ssl, char **proxy_ur
{
git_config *cfg;
git_config_entry *ce = NULL;
- const char *val = NULL;
+ git_buf val = GIT_BUF_INIT;
int error;
assert(remote);
@@ -789,7 +789,7 @@ int git_remote__get_http_proxy(git_remote *remote, bool use_ssl, char **proxy_ur
return error;
if (ce && ce->value) {
- val = ce->value;
+ *proxy_url = git__strdup(ce->value);
goto found;
}
}
@@ -797,19 +797,28 @@ int git_remote__get_http_proxy(git_remote *remote, bool use_ssl, char **proxy_ur
/* http.proxy config setting */
if ((error = git_config__lookup_entry(&ce, cfg, "http.proxy", false)) < 0)
return error;
+
if (ce && ce->value) {
- val = ce->value;
+ *proxy_url = git__strdup(ce->value);
goto found;
}
/* HTTP_PROXY / HTTPS_PROXY environment variables */
- val = use_ssl ? getenv("HTTPS_PROXY") : getenv("HTTP_PROXY");
+ error = git__getenv(&val, use_ssl ? "HTTPS_PROXY" : "HTTP_PROXY");
-found:
- if (val && val[0]) {
- *proxy_url = git__strdup(val);
- GITERR_CHECK_ALLOC(*proxy_url);
+ if (error < 0) {
+ if (error == GIT_ENOTFOUND) {
+ giterr_clear();
+ error = 0;
+ }
+
+ return error;
}
+
+ *proxy_url = git_buf_detach(&val);
+
+found:
+ GITERR_CHECK_ALLOC(*proxy_url);
git_config_entry_free(ce);
return 0;