Skip to content

Commit ab85a7d

Browse files
committed
Merge branch 'ws/single-file-cone'
The logic to see if we are using the "cone" mode by checking the sparsity patterns has been tightened to avoid mistaking a pattern that names a single file as specifying a cone. * ws/single-file-cone: dir: check for single file cone patterns
2 parents 1120c54 + 5842710 commit ab85a7d

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

dir.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -732,6 +732,13 @@ static void add_pattern_to_hashsets(struct pattern_list *pl, struct path_pattern
732732
goto clear_hashmaps;
733733
}
734734

735+
if (!(given->flags & PATTERN_FLAG_MUSTBEDIR) &&
736+
strcmp(given->pattern, "/*")) {
737+
/* Not a cone pattern. */
738+
warning(_("unrecognized pattern: '%s'"), given->pattern);
739+
goto clear_hashmaps;
740+
}
741+
735742
prev = given->pattern;
736743
cur = given->pattern + 1;
737744
next = given->pattern + 2;

t/t1091-sparse-checkout-builtin.sh

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ test_expect_success 'cone mode: match patterns' '
238238
test_expect_success 'cone mode: warn on bad pattern' '
239239
test_when_finished mv sparse-checkout repo/.git/info/ &&
240240
cp repo/.git/info/sparse-checkout . &&
241-
echo "!/deep/deeper/*" >>repo/.git/info/sparse-checkout &&
241+
echo "!/deep/deeper/*/" >>repo/.git/info/sparse-checkout &&
242242
git -C repo read-tree -mu HEAD 2>err &&
243243
test_i18ngrep "unrecognized negative pattern" err
244244
'
@@ -667,6 +667,15 @@ test_expect_success 'pattern-checks: starting "*"' '
667667
check_read_tree_errors repo "a deep" "disabling cone pattern matching"
668668
'
669669

670+
test_expect_success 'pattern-checks: non directory pattern' '
671+
cat >repo/.git/info/sparse-checkout <<-\EOF &&
672+
/deep/deeper1/a
673+
EOF
674+
check_read_tree_errors repo deep "disabling cone pattern matching" &&
675+
check_files repo/deep deeper1 &&
676+
check_files repo/deep/deeper1 a
677+
'
678+
670679
test_expect_success 'pattern-checks: contained glob characters' '
671680
for c in "[a]" "\\" "?" "*"
672681
do

0 commit comments

Comments
 (0)