Skip to content

Commit 78c17b9

Browse files
committed
Merge branch 'sn/http-auth-with-netrc-fix'
* sn/http-auth-with-netrc-fix: http: don't always prompt for password
2 parents de26347 + 986bbc0 commit 78c17b9

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

http.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -279,8 +279,6 @@ static CURL *get_curl_handle(void)
279279
curl_easy_setopt(result, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
280280
#endif
281281

282-
init_curl_http_auth(result);
283-
284282
if (ssl_cert != NULL)
285283
curl_easy_setopt(result, CURLOPT_SSLCERT, ssl_cert);
286284
if (has_cert_password())
@@ -846,7 +844,7 @@ static int http_request(const char *url, void *result, int target, int options)
846844
else if (missing_target(&results))
847845
ret = HTTP_MISSING_TARGET;
848846
else if (results.http_code == 401) {
849-
if (user_name) {
847+
if (user_name && user_pass) {
850848
ret = HTTP_NOAUTH;
851849
} else {
852850
/*
@@ -855,7 +853,8 @@ static int http_request(const char *url, void *result, int target, int options)
855853
* but that is non-portable. Using git_getpass() can at least be stubbed
856854
* on other platforms with a different implementation if/when necessary.
857855
*/
858-
user_name = xstrdup(git_getpass_with_description("Username", description));
856+
if (!user_name)
857+
user_name = xstrdup(git_getpass_with_description("Username", description));
859858
init_curl_http_auth(slot->curl);
860859
ret = HTTP_REAUTH;
861860
}

0 commit comments

Comments
 (0)