Skip to content

Commit

Permalink
Merge branch 'sn/http-auth-with-netrc-fix'
Browse files Browse the repository at this point in the history
* sn/http-auth-with-netrc-fix:
  http: don't always prompt for password
  • Loading branch information
Junio C Hamano committed Nov 7, 2011
2 parents de26347 + 986bbc0 commit 78c17b9
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions http.c
Original file line number Diff line number Diff line change
Expand Up @@ -279,8 +279,6 @@ static CURL *get_curl_handle(void)
curl_easy_setopt(result, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
#endif

init_curl_http_auth(result);

if (ssl_cert != NULL)
curl_easy_setopt(result, CURLOPT_SSLCERT, ssl_cert);
if (has_cert_password())
Expand Down Expand Up @@ -846,7 +844,7 @@ static int http_request(const char *url, void *result, int target, int options)
else if (missing_target(&results))
ret = HTTP_MISSING_TARGET;
else if (results.http_code == 401) {
if (user_name) {
if (user_name && user_pass) {
ret = HTTP_NOAUTH;
} else {
/*
Expand All @@ -855,7 +853,8 @@ static int http_request(const char *url, void *result, int target, int options)
* but that is non-portable. Using git_getpass() can at least be stubbed
* on other platforms with a different implementation if/when necessary.
*/
user_name = xstrdup(git_getpass_with_description("Username", description));
if (!user_name)
user_name = xstrdup(git_getpass_with_description("Username", description));
init_curl_http_auth(slot->curl);
ret = HTTP_REAUTH;
}
Expand Down

0 comments on commit 78c17b9

Please sign in to comment.