Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -682,7 +682,7 @@ static void add_pattern_to_hashsets(struct pattern_list *pl, struct path_pattern
return;
}

if (given->patternlen <= 2 ||
if (given->patternlen < 2 ||
*given->pattern == '*' ||
strstr(given->pattern, "**")) {
/* Not a cone pattern. */
Expand Down
12 changes: 11 additions & 1 deletion t/t1091-sparse-checkout-builtin.sh
Original file line number Diff line number Diff line change
Expand Up @@ -417,10 +417,20 @@ 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_expect_success 'pattern-checks: not too short' '
cat >repo/.git/info/sparse-checkout <<-\EOF &&
/*
!/*/
/b/
EOF
git -C repo read-tree -mu HEAD 2>err &&
test_must_be_empty err &&
check_files repo a
'

test_expect_success 'pattern-checks: trailing "*"' '
cat >repo/.git/info/sparse-checkout <<-\EOF &&
Expand Down