sparse-checkout: escape all glob characters on write
The sparse-checkout patterns allow special globs according to fnmatch(3). When writing cone-mode patterns for paths containing these characters, they must be escaped. Use is_glob_special() to check which characters must be escaped this way, and add a path to the tests that contains all glob characters at once. Note that ']' is not special, since the initial bracket '[' is escaped. Reported-by: Jeff King <peff@peff.net> Signed-off-by: Derrick Stolee <dstolee@microsoft.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
committed by
Junio C Hamano
parent
e55682ea26
commit
e53ffe2704
@ -149,7 +149,7 @@ static char *escaped_pattern(char *pattern)
|
||||
struct strbuf final = STRBUF_INIT;
|
||||
|
||||
while (*p) {
|
||||
if (*p == '*' || *p == '\\')
|
||||
if (is_glob_special(*p))
|
||||
strbuf_addch(&final, '\\');
|
||||
|
||||
strbuf_addch(&final, *p);
|
||||
|
||||
Reference in New Issue
Block a user