summaryrefslogtreecommitdiff
path: root/builtin/sparse-checkout.c
diff options
context:
space:
mode:
authorDerrick Stolee <dstolee@microsoft.com>2020-01-31 20:16:13 (GMT)
committerJunio C Hamano <gitster@pobox.com>2020-01-31 21:05:29 (GMT)
commite53ffe2704d7e10690f4382e46c1411a482531f1 (patch)
tree7f3023dee345428454e54871094f1d9d51def9e9 /builtin/sparse-checkout.c
parente55682ea2640dd3aa002a2657c32bdd1d85b44e9 (diff)
downloadgit-e53ffe2704d7e10690f4382e46c1411a482531f1.zip
git-e53ffe2704d7e10690f4382e46c1411a482531f1.tar.gz
git-e53ffe2704d7e10690f4382e46c1411a482531f1.tar.bz2
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>
Diffstat (limited to 'builtin/sparse-checkout.c')
-rw-r--r--builtin/sparse-checkout.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/builtin/sparse-checkout.c b/builtin/sparse-checkout.c
index facdb6b..7aeb384 100644
--- a/builtin/sparse-checkout.c
+++ b/builtin/sparse-checkout.c
@@ -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);