Re: [Wishlist] could git tell which password it is asking when asking a password.

Subsystems: the rest

2 messages, 2 authors, 2016-06-15 · open the first message on its own page

Re: [Wishlist] could git tell which password it is asking when asking a password.

From: Junio C Hamano <hidden>
Date: 2016-06-15 22:51:32

Junio C Hamano [off-list ref] writes:
... So an alternative route
may be to keep git_getpass() as-is, and update the init_curl_http_auth()
callsite to include the username (but imap-send assumes that user and host
are relatively short without verifying that assumption, and should not be
used as a model of good existing code).
And here is such a lazy patch, completely untested, of course ;-).

 http.c |    7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/http.c b/http.c
index b2ae8de..44948a7 100644
--- a/http.c
+++ b/http.c
@@ -209,8 +209,11 @@ static void init_curl_http_auth(CURL *result)
 {
 	if (user_name) {
 		struct strbuf up = STRBUF_INIT;
-		if (!user_pass)
-			user_pass = xstrdup(git_getpass("Password: "));
+		if (!user_pass) {
+			strbuf_addf(&up, "Password for %s: ", user_name);
+			user_pass = xstrdup(git_getpass(up.buf));
+			strbuf_reset(&up);
+		}
 		strbuf_addf(&up, "%s:%s", user_name, user_pass);
 		curl_easy_setopt(result, CURLOPT_USERPWD,
 				 strbuf_detach(&up, NULL));

Re: [Wishlist] could git tell which password it is asking when asking a password.

From: Shawn Pearce <hidden>
Date: 2016-06-15 22:51:32

On Fri, Jul 1, 2011 at 10:16, Junio C Hamano [off-list ref] wrote:
quoted hunk
Junio C Hamano [off-list ref] writes:
diff --git a/http.c b/http.c
index b2ae8de..44948a7 100644
--- a/http.c
+++ b/http.c
@@ -209,8 +209,11 @@ static void init_curl_http_auth(CURL *result)
 {
       if (user_name) {
               struct strbuf up = STRBUF_INIT;
-               if (!user_pass)
-                       user_pass = xstrdup(git_getpass("Password: "));
+               if (!user_pass) {
+                       strbuf_addf(&up, "Password for %s: ", user_name);
The user_name by itself may not be sufficient. I may also need the URL
to correctly answer the question. I don't always use the same password
on every website. :-)

As a human sure, I know what URL I asked Git to poke for me. But if I
want to write a script that looks this up in a password manager for
me, that script needs the URL.

Food for thought.

-- 
Shawn.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help