diff mbox series

[v3,14/26] rm: ensure full index

Message ID 175f3bc6b336539700d50b1906fd2a33c0bed906.1618261698.git.gitgitgadget@gmail.com (mailing list archive)
State Accepted
Commit e43e2a17d2d4f63a277a7fdbc32453876c25e06c
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>
---
 builtin/rm.c | 2 ++
 1 file changed, 2 insertions(+)
diff mbox series

Patch

diff --git a/builtin/rm.c b/builtin/rm.c
index 4858631e0f02..5559a0b453a3 100644
--- a/builtin/rm.c
+++ b/builtin/rm.c
@@ -293,6 +293,8 @@  int cmd_rm(int argc, const char **argv, const char *prefix)
 
 	seen = xcalloc(pathspec.nr, 1);
 
+	/* TODO: audit for interaction with sparse-index. */
+	ensure_full_index(&the_index);
 	for (i = 0; i < active_nr; i++) {
 		const struct cache_entry *ce = active_cache[i];
 		if (!ce_path_match(&the_index, ce, &pathspec, seen))