mirror of
https://github.com/git/git.git
synced 2026-04-02 13:00:08 +02:00
Add a simple getpass() for MinGW
This should be replaced with a graphical getpass() at some stage. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user