Skip to content

Commit

Permalink
wincred: accept CRLF on stdin to simplify console usage
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Karsten Blees authored and Erik Faye-Lund committed Feb 26, 2013
1 parent 4dac067 commit 3b12f46
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions contrib/credential/wincred/git-credential-wincred.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 3b12f46

Please sign in to comment.