diff options
author | Edward Thomson <ethomson@edwardthomson.com> | 2021-09-20 08:39:46 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-09-20 08:39:46 -0400 |
commit | 0644c2e8c54784800f27ee7b389eccaff6745755 (patch) | |
tree | e0b4c438940763649aac6190683f0f38d3003a66 /src | |
parent | 4f5653a4b524db88cf3e6c6744bb71ad2394b9b9 (diff) | |
parent | 3bd462a113a9bbf4fb6e61c56c3a32ac3636b664 (diff) | |
download | libgit2-0644c2e8c54784800f27ee7b389eccaff6745755.tar.gz |
Merge pull request #6058 from mathworks/proxy_config_with_detached_remote
Allow proxy options when connecting with a detached remote.
Diffstat (limited to 'src')
-rw-r--r-- | src/remote.c | 15 |
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; |