diff mbox series

[v3,05/26] add: ensure full index

Message ID b59c9f482828c54cfa8ccc2022cb72b60833daf5.1618261698.git.gitgitgadget@gmail.com (mailing list archive)
State Accepted
Commit 54beed24d22867a98fc247e1031e3486573f1553
Headers show
Series Sparse Index: API protections | expand

Commit Message

Derrick Stolee April 12, 2021, 9:07 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/add.c | 2 ++
 1 file changed, 2 insertions(+)
diff mbox series

Patch

diff --git a/builtin/add.c b/builtin/add.c
index ea762a41e3a2..afccf2fd5543 100644
--- a/builtin/add.c
+++ b/builtin/add.c
@@ -141,6 +141,8 @@  static int renormalize_tracked_files(const struct pathspec *pathspec, int flags)
 {
 	int i, retval = 0;
 
+	/* TODO: audit for interaction with sparse-index. */
+	ensure_full_index(&the_index);
 	for (i = 0; i < active_nr; i++) {
 		struct cache_entry *ce = active_cache[i];