Commit c8823fb05097cf38fa7f5cce0929e63c186f7a21

Laurence McGlashan 2021-09-18T21:00:48

Apply suggestions from code review Co-authored-by: Edward Thomson <ethomson@github.com>

diff --git a/src/remote.c b/src/remote.c
index 9f604c3..2ff1f7d 100644
--- a/src/remote.c
+++ b/src/remote.c
@@ -888,19 +888,16 @@ static int http_proxy_config(char **out, git_remote *remote, git_net_url *url)
 	git_buf buf = GIT_BUF_INIT;
 	git_net_url lookup_url = GIT_NET_URL_INIT;
 	int error;
-	int cleanup_config = 0;
 
 	if ((error = git_net_url_dup(&lookup_url, url)) < 0)
 		goto done;
 
 	if (remote->repo) {
-		if ((error = git_repository_config__weakptr(&cfg, remote->repo)) < 0)
+		if ((error = git_repository_config(&cfg, remote->repo)) < 0)
 			goto done;
 	} else {
 		if ((error = git_config_open_default(&cfg)) < 0)
 			goto done;
-
-		cleanup_config = 1;
 	}
 
 	/* remote.<name>.proxy config setting */
@@ -932,9 +929,7 @@ static int http_proxy_config(char **out, git_remote *remote, git_net_url *url)
 	error = lookup_config(out, cfg, "http.proxy");
 
 done:
-	if (cleanup_config)
-		git_config_free(cfg);
-
+	git_config_free(cfg);
 	git_buf_dispose(&buf);
 	git_net_url_dispose(&lookup_url);
 	return error;