Skip to content

Commit 0dbbbc1

Browse files
dschogitster
authored andcommitted
MinGW: Add a simple getpass()
We need getpass() to activate curl on MinGW. Although the default Makefile currently has 'NO_CURL = YesPlease', msysgit releases do provide curl support, so getpass() is used. [spr: - edited commit message. - squashed commit that provides getpass() declaration.] Signed-off-by: Johannes Schindelin <[email protected]> Signed-off-by: Steffen Prohaska <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 27e3219 commit 0dbbbc1

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

compat/mingw.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1156,3 +1156,18 @@ int link(const char *oldpath, const char *newpath)
11561156
}
11571157
return 0;
11581158
}
1159+
1160+
char *getpass(const char *prompt)
1161+
{
1162+
struct strbuf buf = STRBUF_INIT;
1163+
1164+
fputs(prompt, stderr);
1165+
for (;;) {
1166+
char c = _getch();
1167+
if (c == '\r' || c == '\n')
1168+
break;
1169+
strbuf_addch(&buf, c);
1170+
}
1171+
fputs("\n", stderr);
1172+
return strbuf_detach(&buf, NULL);
1173+
}

compat/mingw.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ struct passwd {
3838
char *pw_dir;
3939
};
4040

41+
extern char *getpass(const char *prompt);
42+
4143
struct pollfd {
4244
int fd; /* file descriptor */
4345
short events; /* requested events */

0 commit comments

Comments
 (0)