git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH v2 1/2] wincred: accept CRLF on stdin to simplify console usage

From
Karsten Blees <karsten.blees@gmail.com>
Date
Jan 10, 2013, 12:10 UTC
Message-ID
<50EEAFA1.2030000@dcon.de>
In-Reply-To
<CABPQNSb7MjTKgmeB9TcUV0+-FfjPZ1sgKPsfVDg6+uaw2f_azQ@mail.gmail.com>

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>
---
 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

-- 
*** Please reply-to-all at all times ***
*** (do not pretend to know who is subscribed and who is not) ***
*** Please avoid top-posting. ***
The msysGit Wiki is here: https://github.com/msysgit/msysgit/wiki - Github accounts are free.

You received this message because you are subscribed to the Google
Groups "msysGit" group.
To post to this group, send email to msysgit@googlegroups.com
To unsubscribe from this group, send email to
msysgit+unsubscribe@googlegroups.com
For more options, and view previous threads, visit this group at
http://groups.google.com/group/msysgit?hl=en_US?hl=en
Previous: Johannes SchindelinNext: Karsten Blees
Message 13 of 15 in “wincred: improve compatibility with windows versions”
  1. wincred: improve compatibility with windows versionsKarsten Blees, Jan 4, 2013
  2. Erik Faye-LundJan 4, 2013
  3. Karsten BleesJan 8, 2013
  4. Erik Faye-LundJan 8, 2013
  5. 0/2 improve-wincred-compatibilityKarsten Blees, Jan 10, 2013
  6. Erik Faye-LundJan 11, 2013
  7. Junio C HamanoFeb 25, 2013
  8. Karsten BleesFeb 25, 2013
  9. Junio C HamanoFeb 25, 2013
  10. Erik Faye-LundFeb 26, 2013
  11. Junio C HamanoFeb 26, 2013
  12. Johannes SchindelinFeb 26, 2013
  13. 1/2 wincred: accept CRLF on stdin to simplify console usageKarsten Blees, Jan 10, 2013
  14. 2/2 wincred: improve compatibility with windows versionsKarsten Blees, Jan 10, 2013
  15. Erik Faye-LundSep 10, 2014

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.