зеркало из https://github.com/microsoft/git.git
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>
This commit is contained in:
Родитель
41de0c6fbc
Коммит
9e6d3e6417
3
dir.c
3
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;
|
||||
|
|
|
@ -339,4 +339,13 @@ test_expect_success 'pattern-checks: /A/**/B/' '
|
|||
check_files repo/deep/deeper1 "deepest"
|
||||
'
|
||||
|
||||
test_expect_success 'pattern-checks: too short' '
|
||||
cat >repo/.git/info/sparse-checkout <<-\EOF &&
|
||||
/*
|
||||
!/*/
|
||||
/a
|
||||
EOF
|
||||
check_read_tree_errors repo "a" "disabling cone pattern matching"
|
||||
'
|
||||
|
||||
test_done
|
||||
|
|
Загрузка…
Ссылка в новой задаче