1
0
Fork 0
mirror of https://github.com/git/git.git synced 2024-06-08 13:36:15 +02:00

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>
This commit is contained in:
Kevin Ballard 2008-08-13 15:34:34 -07:00 committed by Junio C Hamano
parent 9612e74342
commit ea335b56d4
2 changed files with 9 additions and 1 deletions

2
dir.c
View File

@ -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 == '\\';
}
/*

View File

@ -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