# remove CR/LF from .gitignore

3 messages from 2005-11-02 to 2005-11-02. Participants: Alex Riesen, Linus Torvalds, Junio C Hamano.
Thread: https://gitlist.dev/t/2314

## Alex Riesen, 2005-11-02 13:05

Subject: remove CR/LF from .gitignore
Message-ID: <81b0412b0511020505u1b6b7649l924e252d561b8e9e@mail.gmail.com>
URL: https://gitlist.dev/e/81b0412b0511020505u1b6b7649l924e252d561b8e9e%40mail.gmail.com

```
For everyone cursed by dos/windows line endings (aka CRLF):

The code reading the .gitignore files (excludes and excludes per
directory) leaves \r in the patterns, which causes fnmatch to fail for
no obvious reason. Just remove a "\r" preceding a "\n"
unconditionally.

---

Junio, sorry for attachments. Have no other way to it on gmail here at
work. The other patch is just the test.

```

## Linus Torvalds, 2005-11-02 16:02

Subject: Re: remove CR/LF from .gitignore
Message-ID: <Pine.LNX.4.64.0511020759500.27915@g5.osdl.org>
URL: https://gitlist.dev/e/Pine.LNX.4.64.0511020759500.27915%40g5.osdl.org
In-Reply-To: <81b0412b0511020505u1b6b7649l924e252d561b8e9e@mail.gmail.com>

```


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

		Linus

```

## Junio C Hamano, 2005-11-02 20:27

Subject: Re: remove CR/LF from .gitignore
Message-ID: <7v1x1yssmd.fsf@assigned-by-dhcp.cox.net>
URL: https://gitlist.dev/e/7v1x1yssmd.fsf%40assigned-by-dhcp.cox.net
In-Reply-To: <Pine.LNX.4.64.0511020759500.27915@g5.osdl.org>

```
Linus Torvalds <torvalds@osdl.org> writes:

> 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

```
