{"thread":{"id":"14994","subject":"[PATCH] Fix escaping of glob special characters in pathspecs","startedAt":"2008-08-13T22:34:34Z","lastAt":"2008-08-13T22:34:34Z","messageCount":1,"participants":["Kevin Ballard"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"87120","messageId":"1218666874-85937-1-git-send-email-kevin@sb.org","threadId":"14994","inReplyTo":null,"subject":"[PATCH] Fix escaping of glob special characters in pathspecs","fromName":"Kevin Ballard","fromEmail":"kevin@sb.org","sentAt":"2008-08-13T22:34:34Z","receivedAt":"2008-08-13T22:34:34Z","isPatch":true,"sender":{"key":"kevin@sb.org","avatar":"https://avatars.githubusercontent.com/u/714?v=4"},"body":"match_one implements an optimized pathspec match where it only uses\nfnmatch if it detects glob special characters in the pattern. Unfortunately\nit didn't treat \\ as a special character, so attempts to escape a glob\nspecial character would fail even though fnmatch() supports it.\n\nSigned-off-by: Kevin Ballard <kevin@sb.org>\n---\n dir.c          |    2 +-\n t/t3700-add.sh |    8 ++++++++\n 2 files changed, 9 insertions(+), 1 deletions(-)\n\ndiff --git a/dir.c b/dir.c\nindex 29d1d5b..109e05b 100644\n--- a/dir.c\n+++ b/dir.c\n@@ -54,7 +54,7 @@ int common_prefix(const char **pathspec)\n \n static inline int special_char(unsigned char c1)\n {\n-\treturn !c1 || c1 == '*' || c1 == '[' || c1 == '?';\n+\treturn !c1 || c1 == '*' || c1 == '[' || c1 == '?' || c1 == '\\\\';\n }\n \n /*\ndiff --git a/t/t3700-add.sh b/t/t3700-add.sh\nindex 7d123d1..77a782c 100755\n--- a/t/t3700-add.sh\n+++ b/t/t3700-add.sh\n@@ -222,4 +222,12 @@ test_expect_success 'git add (add.ignore-errors = false)' '\n \t! ( git ls-files foo1 | grep foo1 )\n '\n \n+test_expect_success 'git add '\\''fo\\?bar'\\'' ignores foobar' '\n+\tgit reset --hard &&\n+\ttouch fo\\?bar foobar &&\n+\tgit add '\\''fo\\?bar'\\'' &&\n+\tgit ls-files fo\\?bar | grep -F fo\\?bar &&\n+\t! ( git ls-files foobar | grep foobar )\n+'\n+\n test_done\n-- \n1.6.0.rc3.1.g9002abb\n"}]}