[PATCH 4/5] MinGW: Add a simple getpass()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Johannes Schindelin <johannes.schindelin@xxxxxx>

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@xxxxxx>
Signed-off-by: Steffen Prohaska <prohaska@xxxxxx>
---
 compat/mingw.c |   15 +++++++++++++++
 compat/mingw.h |    2 ++
 2 files changed, 17 insertions(+), 0 deletions(-)

diff --git a/compat/mingw.c b/compat/mingw.c
index b723c4d..e190fdd 100644
--- a/compat/mingw.c
+++ b/compat/mingw.c
@@ -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);
+}
diff --git a/compat/mingw.h b/compat/mingw.h
index b1156b8..4c50f5b 100644
--- a/compat/mingw.h
+++ b/compat/mingw.h
@@ -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 */
-- 
1.6.3.1.54.g99dd

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]