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

[PATCH] Add a simple getpass() for MinGW

From
Johannes Schindelin <johannes.schindelin@gmx.de>
Date
Apr 8, 2009, 01:30 UTC
Message-ID
<7ba615a300fe2742e8d32f0313c6ee9a1a1aaed3.1239154140u.git.johannes.schindelin@gmx.de>
In-Reply-To
<cover.1239154140u.git.johannes.schindelin@gmx.de>
This should be replaced with a graphical getpass() at some stage.
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---
	I saw it coming that I had to do this.
 compat/mingw.c |   15 +++++++++++++++
 1 files changed, 15 insertions(+), 0 deletions(-)
diff --git a/compat/mingw.c b/compat/mingw.c
index d50186e..2ab5bbe 100644
--- a/compat/mingw.c
+++ b/compat/mingw.c
@@ -1157,3 +1157,18 @@ int link(const char *oldpath, const char *newpath)
 	}
 	return 0;
 }
+
+char *getpass(const char *prompt)
+{
+	struct strbuf buf = STRBUF_INIT;
+
+	fputs(prompt, stderr);
+	for (;;) {
+		char c = _getch();
+		if (c == '\r' || c == '\n')
+			break;
+		strbuf_addch(&buf, c);
+	}
+	fputs("\n", stderr);
+	return strbuf_detach(&buf, NULL);
+}
-- 
1.6.2.1.613.g25746
Next: Junio C Hamano
Message 1 of 5 in “Add a simple getpass() for MinGW”
  1. Add a simple getpass() for MinGWJohannes Schindelin, Apr 8, 2009
  2. Junio C HamanoApr 8, 2009
  3. Johannes SchindelinApr 8, 2009
  4. Johannes SixtApr 9, 2009
  5. Johannes SchindelinApr 10, 2009

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.