Skip to content

Commit

Permalink
MinGW: Add a simple getpass()
Browse files Browse the repository at this point in the history
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 <johannes.schindelin@gmx.de>
Signed-off-by: Steffen Prohaska <prohaska@zib.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Johannes Schindelin authored and Junio C Hamano committed May 23, 2009
1 parent 27e3219 commit 0dbbbc1
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
15 changes: 15 additions & 0 deletions compat/mingw.c
Original file line number Diff line number Diff line change
Expand Up @@ -1156,3 +1156,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);
}
2 changes: 2 additions & 0 deletions compat/mingw.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ struct passwd {
char *pw_dir;
};

extern char *getpass(const char *prompt);

struct pollfd {
int fd; /* file descriptor */
short events; /* requested events */
Expand Down

0 comments on commit 0dbbbc1

Please sign in to comment.