提交 ea335b56 编写于 作者: K Kevin Ballard 提交者: Junio C Hamano

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: NKevin Ballard <kevin@sb.org>
Signed-off-by: NJunio C Hamano <gitster@pobox.com>
上级 9612e743
......@@ -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 == '\\';
}
/*
......
......@@ -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
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册