Skip to content

Commit 072a231

Browse files
newrengitster
authored andcommitted
dir: exit before wildcard fall-through if there is no wildcard
The DO_MATCH_LEADING_PATHSPEC had a fall-through case for if there was a wildcard, noting that we don't yet have enough information to determine if a further paths under the current directory might match due to the presence of wildcards. But if we have no wildcards in our pathspec, then we shouldn't get to that fall-through case. Signed-off-by: Elijah Newren <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 2f5d384 commit 072a231

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

dir.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -379,6 +379,13 @@ static int match_pathspec_item(const struct index_state *istate,
379379
item->nowildcard_len - prefix))
380380
return 0;
381381

382+
/*
383+
* name has no wildcard, and it didn't match as a leading
384+
* pathspec so return.
385+
*/
386+
if (item->nowildcard_len == item->len)
387+
return 0;
388+
382389
/*
383390
* Here is where we would perform a wildmatch to check if
384391
* "name" can be matched as a directory (or a prefix) against

t/t3011-common-prefixes-and-directory-traversal.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ test_expect_failure 'git ls-files -o untracked_repo/ does not recurse' '
9292
test_cmp expect actual
9393
'
9494

95-
test_expect_failure 'git ls-files -o untracked_dir untracked_repo recurses into untracked_dir only' '
95+
test_expect_success 'git ls-files -o untracked_dir untracked_repo recurses into untracked_dir only' '
9696
cat <<-EOF >expect &&
9797
untracked_dir/empty
9898
untracked_repo/
@@ -110,7 +110,7 @@ test_expect_success 'git ls-files -o untracked_dir/ untracked_repo/ recurses int
110110
test_cmp expect actual
111111
'
112112

113-
test_expect_failure 'git ls-files -o --directory untracked_dir untracked_repo does not recurse' '
113+
test_expect_success 'git ls-files -o --directory untracked_dir untracked_repo does not recurse' '
114114
cat <<-EOF >expect &&
115115
untracked_dir/
116116
untracked_repo/

0 commit comments

Comments
 (0)