pathspec: ensure full index

Before iterating over all cache entries, ensure that a sparse index is expanded to a full index to avoid unexpected behavior. Signed-off-by: Derrick Stolee <dstolee@microsoft.com> Reviewed-by: Elijah Newren <newren@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Derrick Stolee committed Apr 1, 2021 at 01:49 UTC 465a04abc6e5f4fe2b93c662bab0319c1667180e
1 file changed +2
pathspec.c
+2
@@ -36,6 +36,8 @@ void add_pathspec_matches_against_index(const struct pathspec *pathspec,
36 num_unmatched++;
37 if (!num_unmatched)
38 return;
39 + /* TODO: audit for interaction with sparse-index. */
40 + ensure_full_index(istate);
41 for (i = 0; i < istate->cache_nr; i++) {
42 const struct cache_entry *ce = istate->cache[i];
43 ce_path_match(istate, ce, pathspec, seen);