From: Karsten Blees Date: Wed, 9 Jan 2013 11:49:26 +0000 (+0100) Subject: wincred: accept CRLF on stdin to simplify console usage X-Git-Tag: v1.8.2-rc2~4^2~1 X-Git-Url: https://repo.or.cz/w/git.git/commitdiff_plain/3b12f46ab382b280effa15a925b6195abaebf0a3 wincred: accept CRLF on stdin to simplify console usage 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 Signed-off-by: Erik Faye-Lund --- diff --git a/contrib/credential/wincred/git-credential-wincred.c b/contrib/credential/wincred/git-credential-wincred.c index cbaec5f24b..94d7140f02 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)