The windows credential helper currently only accepts LF on stdin, but bash
and cmd.exe both send CRLF. This prevents interactive use in the console.

Change the stdin parser to optionally accept CRLF.

Signed-off-by: Karsten Blees <bl...@dcon.de>
---
 contrib/credential/wincred/git-credential-wincred.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/contrib/credential/wincred/git-credential-wincred.c 
b/contrib/credential/wincred/git-credential-wincred.c
index cbaec5f..94d7140 100644
--- a/contrib/credential/wincred/git-credential-wincred.c
+++ b/contrib/credential/wincred/git-credential-wincred.c
@@ -284,10 +284,13 @@ static void read_credential(void)
 
        while (fgets(buf, sizeof(buf), stdin)) {
                char *v;
+               int len = strlen(buf);
+               /* strip trailing CR / LF */
+               while (len && strchr("\r\n", buf[len - 1]))
+                       buf[--len] = 0;
 
-               if (!strcmp(buf, "\n"))
+               if (!*buf)
                        break;
-               buf[strlen(buf)-1] = '\0';
 
                v = strchr(buf, '=');
                if (!v)
-- 
1.8.0.msysgit.0.4.g4e40dea

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

Reply via email to