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 <blees@dcon.de> Signed-off-by: Erik Faye-Lund <kusmabite@gmail.com>

Karsten Blees committed Jan 9, 2013 at 12:49 UTC 3b12f46ab382b280effa15a925b6195abaebf0a3
1 file changed +5 -2
contrib/credential/wincred/git-credential-wincred.c
+5 -2
@@ -284,10 +284,13 @@ static void read_credential(void)
284
285 while (fgets(buf, sizeof(buf), stdin)) {
286 char *v;
287 + int len = strlen(buf);
288 + /* strip trailing CR / LF */
289 + while (len && strchr("\r\n", buf[len - 1]))
290 + buf[--len] = 0;
291
288 - if (!strcmp(buf, "\n"))
292 + if (!*buf)
293 break;
290 - buf[strlen(buf)-1] = '\0';
294
295 v = strchr(buf, '=');
296 if (!v)