Skip to content

Commit 3b12f46

Browse files
kbleeskusma
authored andcommitted
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 <[email protected]> Signed-off-by: Erik Faye-Lund <[email protected]>
1 parent 4dac067 commit 3b12f46

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

contrib/credential/wincred/git-credential-wincred.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -284,10 +284,13 @@ static void read_credential(void)
284284

285285
while (fgets(buf, sizeof(buf), stdin)) {
286286
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;
287291

288-
if (!strcmp(buf, "\n"))
292+
if (!*buf)
289293
break;
290-
buf[strlen(buf)-1] = '\0';
291294

292295
v = strchr(buf, '=');
293296
if (!v)

0 commit comments

Comments
 (0)