summaryrefslogtreecommitdiff
path: root/remote-curl.c
diff options
context:
space:
mode:
authorScott Chacon <schacon@gmail.com>2010-04-01 15:14:35 -0700
committerJunio C Hamano <gitster@pobox.com>2010-04-01 23:24:59 -0700
commit42653c09c85015addc6fa8dd4d49cb250253412e (patch)
treecd33603246f89be8c771ff51284f9833bc565efa /remote-curl.c
parent890a13a45285ad44858add2ce2f74eb478f549c8 (diff)
downloadgit-42653c09c85015addc6fa8dd4d49cb250253412e.tar.gz
Prompt for a username when an HTTP request 401s
When an HTTP request returns a 401, Git will currently fail with a confusing message saying that it got a 401, which is not very descriptive. Currently if a user wants to use Git over HTTP, they have to use one URL with the username in the URL (e.g. "http://user@host.com/repo.git") for write access and another without the username for unauthenticated read access (unless they want to be prompted for the password each time). However, since the HTTP servers will return a 401 if an action requires authentication, we can prompt for username and password if we see this, allowing us to use a single URL for both purposes. This patch changes http_request to prompt for the username and password, then return HTTP_REAUTH so http_get_strbuf can try again. If it gets a 401 even when a user/pass is supplied, http_request will now return HTTP_NOAUTH which remote_curl can then use to display a more intelligent error message that is less confusing. Signed-off-by: Scott Chacon <schacon@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'remote-curl.c')
-rw-r--r--remote-curl.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/remote-curl.c b/remote-curl.c
index b76bfcb3d3..07827562b5 100644
--- a/remote-curl.c
+++ b/remote-curl.c
@@ -132,6 +132,8 @@ static struct discovery* discover_refs(const char *service)
case HTTP_MISSING_TARGET:
die("%s not found: did you run git update-server-info on the"
" server?", refs_url);
+ case HTTP_NOAUTH:
+ die("Authentication failed");
default:
http_error(refs_url, http_ret);
die("HTTP request failed");