diff mbox series

[v3,20/26] pathspec: ensure full index

Message ID 4d3f6de29a6393e46923bbaece69ed7e21a03101.1618261698.git.gitgitgadget@gmail.com (mailing list archive)
State Accepted
Commit 465a04abc6e5f4fe2b93c662bab0319c1667180e
Headers show
Series Sparse Index: API protections | expand

Commit Message

Derrick Stolee April 12, 2021, 9:08 p.m. UTC
From: Derrick Stolee <dstolee@microsoft.com>

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>
---
 pathspec.c | 2 ++
 1 file changed, 2 insertions(+)
diff mbox series

Patch

diff --git a/pathspec.c b/pathspec.c
index b6e333965cb4..d67688bab74b 100644
--- a/pathspec.c
+++ b/pathspec.c
@@ -36,6 +36,8 @@  void add_pathspec_matches_against_index(const struct pathspec *pathspec,
 			num_unmatched++;
 	if (!num_unmatched)
 		return;
+	/* TODO: audit for interaction with sparse-index. */
+	ensure_full_index(istate);
 	for (i = 0; i < istate->cache_nr; i++) {
 		const struct cache_entry *ce = istate->cache[i];
 		ce_path_match(istate, ce, pathspec, seen);