@matheusbsbs / matheus-bagliano / commits / 072a231016
Fork 0

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 <newren@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Elijah Newren committed Dec 10, 2019 at 20:00 UTC 072a231016e5da347c3a8ff38afb72e7876dd1d7
2 files changed +9 -2
dir.c
+7
@@ -379,6 +379,13 @@ static int match_pathspec_item(const struct index_state *istate,
379 item->nowildcard_len - prefix))
380 return 0;
381
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 +
389 /*
390 * Here is where we would perform a wildmatch to check if
391 * "name" can be matched as a directory (or a prefix) against
t/t3011-common-prefixes-and-directory-traversal.sh
+2 -2
@@ -92,7 +92,7 @@ test_expect_failure 'git ls-files -o untracked_repo/ does not recurse' '
92 test_cmp expect actual
93 '
94
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' '
96 cat <<-EOF >expect &&
97 untracked_dir/empty
98 untracked_repo/
@@ -110,7 +110,7 @@ test_expect_success 'git ls-files -o untracked_dir/ untracked_repo/ recurses int
110 test_cmp expect actual
111 '
112
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' '
114 cat <<-EOF >expect &&
115 untracked_dir/
116 untracked_repo/