git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 1/1] credential: do not mask the username

From
JGJarosław Honkis via GitGitGadget <gitgitgadget@gmail.com>
Date
Apr 29, 2019, 22:06 UTC
Message-ID
<e459e487d3848ae1b7f37676bd9d2a2f9c967430.1556575570.git.gitgitgadget@gmail.com>
In-Reply-To
<pull.138.git.gitgitgadget@gmail.com>
From: =?UTF-8?q?Jaros=C5=82aw=20Honkis?= <yaras6@gmail.com>

When a user is asked for credentials there is no need to mask the username, so the PROMPT_ASKPASS flag on calling credential_ask_one for login is unnecessary.

The `credential_ask_one()` function internally uses `git_prompt()` which in case it is given the flag PROMPT_ASKPASS uses masked input method instead of git_terminal_prompt, which does not mask user input.

This fixes https://github.com/git-for-windows/git/issue/675
Signed-off-by: Jarosław Honkis <yaras6@gmail.com>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---
 credential.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/credential.c b/credential.c
index 62be651b03..e9108a9e8a 100644
--- a/credential.c
+++ b/credential.c
@@ -136,7 +136,9 @@ static void credential_getpass(struct credential *c)
 {
 	if (!c->username)
 		c->username = credential_ask_one("Username", c,
-						 PROMPT_ASKPASS|PROMPT_ECHO);
+						 (getenv("GIT_ASKPASS") ?
+						  PROMPT_ASKPASS : 0) |
+						 PROMPT_ECHO);
 	if (!c->password)
 		c->password = credential_ask_one("Password", c,
 						 PROMPT_ASKPASS);
-- 
gitgitgadget
Previous: Johannes Schindelin via GitGitGadgetNext: Eric Sunshine
Message 2 of 8 in “credential: do not mask the username”
  1. 0/1 credential: do not mask the usernameJohannes Schindelin via GitGitGadget, Apr 29, 2019
  2. 1/1 credential: do not mask the usernameJarosław Honkis via GitGitGadget, Apr 29, 2019
  3. Eric SunshineApr 29, 2019
  4. Johannes SchindelinApr 29, 2019
  5. Jeff KingApr 29, 2019
  6. Johannes SchindelinApr 30, 2019
  7. Jeff KingApr 30, 2019
  8. Johannes SchindelinMay 3, 2019

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.