summaryrefslogtreecommitdiff
path: root/dir.c
diff options
context:
space:
mode:
authorDerrick Stolee <dstolee@microsoft.com>2020-01-24 21:19:37 (GMT)
committerJunio C Hamano <gitster@pobox.com>2020-01-24 21:26:54 (GMT)
commit9e6d3e64175713bc0007f3012ea288f4dfc0a399 (patch)
tree1117224847f0b0c6003eced2c04493a49bb5ca2c /dir.c
parent41de0c6fbcc3d2544ebada3a9f26dec0f32f42de (diff)
downloadgit-9e6d3e64175713bc0007f3012ea288f4dfc0a399.zip
git-9e6d3e64175713bc0007f3012ea288f4dfc0a399.tar.gz
git-9e6d3e64175713bc0007f3012ea288f4dfc0a399.tar.bz2
sparse-checkout: detect short patterns
In cone mode, the shortest pattern the sparse-checkout command will write into the sparse-checkout file is "/*". This is handled carefully in add_pattern_to_hashsets(), so warn if any other pattern is this short. This will assist future pattern checks by allowing us to assume there are at least three characters in the pattern. Signed-off-by: Derrick Stolee <dstolee@microsoft.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'dir.c')
-rw-r--r--dir.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/dir.c b/dir.c
index 40fed73..c2e5856 100644
--- a/dir.c
+++ b/dir.c
@@ -651,7 +651,8 @@ static void add_pattern_to_hashsets(struct pattern_list *pl, struct path_pattern
return;
}
- if (strstr(given->pattern, "**")) {
+ if (given->patternlen <= 2 ||
+ strstr(given->pattern, "**")) {
/* Not a cone pattern. */
warning(_("unrecognized pattern: '%s'"), given->pattern);
goto clear_hashmaps;