@matheusbsbs / matheus-bagliano / commits / dd482eeac2
Fork 0

Support "\" in non-wildcard exclusion entries

"\" was treated differently in exclude rules depending on whether a wildcard match was done. For wildcard rules, "\" was de-escaped in fnmatch, but this was not done for other rules since they used strcmp instead. A file named "#foo" would not be excluded by "\#foo", but would be excluded by "\#foo*". We now treat all rules with "\" as wildcard rules. Another solution could be to de-escape all non-wildcard rules as we read them, but we would have to do the de-escaping exactly as fnmatch does it to avoid inconsistencies. Signed-off-by: Finn Arne Gangstad <finnag@pvv.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Finn Arne Gangstad committed Feb 10, 2009 at 15:20 UTC dd482eeac2524627beee323438dd1fdf34b4f97e
2 files changed +9 -2
dir.c
+1 -1
@@ -139,7 +139,7 @@ int match_pathspec(const char **pathspec, const char *name, int namelen, int pre
139
140 static int no_wildcard(const char *string)
141 {
142 - return string[strcspn(string, "*?[{")] == '\0';
142 + return string[strcspn(string, "*?[{\\")] == '\0';
143 }
144
145 void add_exclude(const char *string, const char *base,
t/t3001-ls-files-others-exclude.sh
+8 -1
@@ -19,6 +19,9 @@ do
19 >$dir/a.$i
20 done
21 done
22 +>"#ignore1"
23 +>"#ignore2"
24 +>"#hidden"
25
26 cat >expect <<EOF
27 a.2
@@ -42,6 +45,9 @@ three/a.8
45 EOF
46
47 echo '.gitignore
48 +\#ignore1
49 +\#ignore2*
50 +\#hid*n
51 output
52 expect
53 .gitignore
@@ -79,9 +85,10 @@ test_expect_success \
85 >output &&
86 test_cmp expect output'
87
82 -cat > excludes-file << EOF
88 +cat > excludes-file <<\EOF
89 *.[1-8]
90 e*
91 +\#*
92 EOF
93
94 git config core.excludesFile excludes-file