From ea335b56d44a92b9b8be40b1465d7df65a4f736b Mon Sep 17 00:00:00 2001 From: Kevin Ballard Date: Wed, 13 Aug 2008 15:34:34 -0700 Subject: [PATCH] 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 Signed-off-by: Junio C Hamano --- dir.c | 2 +- t/t3700-add.sh | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/dir.c b/dir.c index 29d1d5ba3..109e05b01 100644 --- a/dir.c +++ b/dir.c @@ -54,7 +54,7 @@ int common_prefix(const char **pathspec) static inline int special_char(unsigned char c1) { - return !c1 || c1 == '*' || c1 == '[' || c1 == '?'; + return !c1 || c1 == '*' || c1 == '[' || c1 == '?' || c1 == '\\'; } /* diff --git a/t/t3700-add.sh b/t/t3700-add.sh index e83fa1f68..fcbc203e7 100755 --- a/t/t3700-add.sh +++ b/t/t3700-add.sh @@ -222,4 +222,12 @@ test_expect_success 'git add (add.ignore-errors = false)' ' ! ( git ls-files foo1 | grep foo1 ) ' +test_expect_success 'git add '\''fo\?bar'\'' ignores foobar' ' + git reset --hard && + touch fo\?bar foobar && + git add '\''fo\?bar'\'' && + git ls-files fo\?bar | grep -F fo\?bar && + ! ( git ls-files foobar | grep foobar ) +' + test_done -- 2.30.2