From 9e6d3e64175713bc0007f3012ea288f4dfc0a399 Mon Sep 17 00:00:00 2001 From: Derrick Stolee Date: Fri, 24 Jan 2020 21:19:37 +0000 Subject: 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 Signed-off-by: Junio C Hamano --- dir.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'dir.c') diff --git a/dir.c b/dir.c index 40fed73a94..c2e585607e 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; -- cgit v1.2.3