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

Fix escaping of glob special characters in pathspecs

match_one implements an optimized pathspec match where it only uses fnmatch if it detects glob special characters in the pattern. Unfortunately it didn't treat \ as a special character, so attempts to escape a glob special character would fail even though fnmatch() supports it. Signed-off-by: Kevin Ballard <kevin@sb.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Kevin Ballard committed Aug 13, 2008 at 15:34 UTC ea335b56d44a92b9b8be40b1465d7df65a4f736b
2 files changed +9 -1
dir.c
+1 -1
@@ -54,7 +54,7 @@ int common_prefix(const char **pathspec)
54
55 static inline int special_char(unsigned char c1)
56 {
57 - return !c1 || c1 == '*' || c1 == '[' || c1 == '?';
57 + return !c1 || c1 == '*' || c1 == '[' || c1 == '?' || c1 == '\\';
58 }
59
60 /*
t/t3700-add.sh
+8
@@ -222,4 +222,12 @@ test_expect_success 'git add (add.ignore-errors = false)' '
222 ! ( git ls-files foo1 | grep foo1 )
223 '
224
225 +test_expect_success 'git add '\''fo\?bar'\'' ignores foobar' '
226 + git reset --hard &&
227 + touch fo\?bar foobar &&
228 + git add '\''fo\?bar'\'' &&
229 + git ls-files fo\?bar | grep -F fo\?bar &&
230 + ! ( git ls-files foobar | grep foobar )
231 +'
232 +
233 test_done