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

Re: remove CR/LF from .gitignore

From
Junio C Hamano <junkio@cox.net>
Date
Nov 2, 2005, 20:27 UTC
Message-ID
<7v1x1yssmd.fsf@assigned-by-dhcp.cox.net>
In-Reply-To
<Pine.LNX.4.64.0511020759500.27915@g5.osdl.org>
Linus Torvalds <torvalds@osdl.org> writes:
Show 10 quoted lines
> On Wed, 2 Nov 2005, Alex Riesen wrote:
>>
>> For everyone cursed by dos/windows line endings (aka CRLF):
>
> Btw, it would be good if somebody verified that the .git/config file also 
> works with CR/LF. 
>
> I'm pretty sure "\" at the end of line will break, but I didn't care 
> enough. And maybe nobody does. Normal config files _should_ work, but 
> you can guess how eager I'm to test it ;)
Something like this?

--- cd /opt/packrat/playpen/public/in-place/git/git.junio/ git diff

diff --git a/config.c b/config.c
index 519fecf..e89bab2 100644
--- a/config.c
+++ b/config.c
@@ -13,6 +13,14 @@ static int get_next_char(void)
 	c = '\n';
 	if ((f = config_file) != NULL) {
 		c = fgetc(f);
+		if (c == '\r') {
+			/* DOS like systems */
+			c = fgetc(f);
+			if (c != '\n') {
+				ungetc(c, f);
+				c = '\r';
+			}
+		}
 		if (c == '\n')
 			config_linenr++;
 		if (c == EOF) {

Compilation finished at Wed Nov  2 12:24:27
Previous: Linus Torvalds
Message 3 of 3 in “remove CR/LF from .gitignore”
  1. Alex RiesenNov 2, 2005
  2. Linus TorvaldsNov 2, 2005
  3. Junio C HamanoNov 2, 2005

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.