summaryrefslogtreecommitdiff
path: root/src/remote.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/remote.c')
-rw-r--r--src/remote.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/src/remote.c b/src/remote.c
index 154300bd2..56d7e42db 100644
--- a/src/remote.c
+++ b/src/remote.c
@@ -884,15 +884,22 @@ static void url_config_trim(git_net_url *url)
static int http_proxy_config(char **out, git_remote *remote, git_net_url *url)
{
- git_config *cfg;
+ git_config *cfg = NULL;
git_buf buf = GIT_BUF_INIT;
git_net_url lookup_url = GIT_NET_URL_INIT;
int error;
- if ((error = git_net_url_dup(&lookup_url, url)) < 0 ||
- (error = git_repository_config__weakptr(&cfg, remote->repo)) < 0)
+ if ((error = git_net_url_dup(&lookup_url, url)) < 0)
goto done;
+ if (remote->repo) {
+ if ((error = git_repository_config(&cfg, remote->repo)) < 0)
+ goto done;
+ } else {
+ if ((error = git_config_open_default(&cfg)) < 0)
+ goto done;
+ }
+
/* remote.<name>.proxy config setting */
if (remote->name && remote->name[0]) {
git_buf_clear(&buf);
@@ -922,6 +929,7 @@ static int http_proxy_config(char **out, git_remote *remote, git_net_url *url)
error = lookup_config(out, cfg, "http.proxy");
done:
+ git_config_free(cfg);
git_buf_dispose(&buf);
git_net_url_dispose(&lookup_url);
return error;
@@ -971,7 +979,6 @@ int git_remote__http_proxy(char **out, git_remote *remote, git_net_url *url)
GIT_ASSERT_ARG(out);
GIT_ASSERT_ARG(remote);
- GIT_ASSERT_ARG(remote->repo);
*out = NULL;