http: use hostname in credential description

Until now, a request for an http password looked like:

  Username:
  Password:

Now it will look like:

  Username for 'example.com':
  Password for 'example.com':

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Jeff King
2011-07-18 03:52:32 -04:00
committed by Junio C Hamano
parent 00b1daa2c1
commit dad8534f86
2 changed files with 5 additions and 6 deletions

7
http.c
View File

@@ -310,7 +310,6 @@ static CURL *get_curl_handle(void)
static void http_auth_init(const char *url)
{
const char *at, *colon, *cp, *slash, *host, *proto_end;
char *decoded;
struct strbuf unique = STRBUF_INIT;
proto_end = strstr(url, "://");
@@ -342,11 +341,11 @@ static void http_auth_init(const char *url)
host = at + 1;
}
http_auth.description = url_decode_mem(host, slash - host);
strbuf_add(&unique, url, proto_end - url);
strbuf_addch(&unique, ':');
decoded = url_decode_mem(host, slash - host);
strbuf_addstr(&unique, decoded);
free(decoded);
strbuf_addstr(&unique, http_auth.description);
http_auth.unique = strbuf_detach(&unique, NULL);
}

View File

@@ -51,8 +51,8 @@ test_expect_success 'setup askpass helpers' '
GIT_ASKPASS="$PWD/askpass" &&
export GIT_ASKPASS &&
>askpass-expect-none &&
echo "askpass: Password: " >askpass-expect-pass &&
{ echo "askpass: Username: " &&
echo "askpass: Password for '\''$HTTPD_DEST'\'': " >askpass-expect-pass &&
{ echo "askpass: Username for '\''$HTTPD_DEST'\'': " &&
cat askpass-expect-pass
} >askpass-expect-both
'