diff mbox series

[v3,17/26] dir: ensure full index

Message ID 08a62c23c8f77c9ea033bf4f7b8e164bdff8b7de.1618261698.git.gitgitgadget@gmail.com (mailing list archive)
State Accepted
Commit d425f65127562e3a7f308b1ccfe385950f96e8ec
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>
---
 dir.c | 2 ++
 1 file changed, 2 insertions(+)
diff mbox series

Patch

diff --git a/dir.c b/dir.c
index 5b00dfb5b144..166238e79f52 100644
--- a/dir.c
+++ b/dir.c
@@ -3533,6 +3533,8 @@  static void connect_wt_gitdir_in_nested(const char *sub_worktree,
 	if (repo_read_index(&subrepo) < 0)
 		die(_("index file corrupt in repo %s"), subrepo.gitdir);
 
+	/* TODO: audit for interaction with sparse-index. */
+	ensure_full_index(subrepo.index);
 	for (i = 0; i < subrepo.index->cache_nr; i++) {
 		const struct cache_entry *ce = subrepo.index->cache[i];