remove CR/LF from .gitignore
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. Signed-off-by: Junio C Hamano <junkio@cox.net>
Alex Riesen committed
Nov 2, 2005 at 14:05 UTC
d317e4384acd5646f2ba44197a531c129b26b57e
2 files changed
+13
-1
ls-files.c
+1
-1
@@ -97,7 +97,7 @@ static int add_excludes_from_file_1(const char *fname,
97
for (i = 0; i < size; i++) {
98
if (buf[i] == '\n') {
99
if (entry != buf + i && entry[0] != '#') {
100
- buf[i] = 0;
100
+ buf[i - (i && buf[i-1] == '\r')] = 0;
101
add_exclude(entry, base, baselen, which);
102
}
103
entry = buf + i + 1;
t/t3001-ls-files-others-exclude.sh
+12
@@ -67,4 +67,16 @@ test_expect_success \
67
>output &&
68
diff -u expect output'
69
70
+# Test \r\n (MSDOS-like systems)
71
+echo -ne '*.1\r\n/*.3\r\n!*.6\r\n' >.gitignore
72
+
73
+test_expect_success \
74
+ 'git-ls-files --others with \r\n line endings.' \
75
+ 'git-ls-files --others \
76
+ --exclude=\*.6 \
77
+ --exclude-per-directory=.gitignore \
78
+ --exclude-from=.git/ignore \
79
+ >output &&
80
+ diff -u expect output'
81
+
82
test_done