dir: 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 d425f65127562e3a7f308b1ccfe385950f96e8ec
1 file changed +2
dir.c
+2
@@ -3533,6 +3533,8 @@ static void connect_wt_gitdir_in_nested(const char *sub_worktree,
3533 if (repo_read_index(&subrepo) < 0)
3534 die(_("index file corrupt in repo %s"), subrepo.gitdir);
3535
3536 + /* TODO: audit for interaction with sparse-index. */
3537 + ensure_full_index(subrepo.index);
3538 for (i = 0; i < subrepo.index->cache_nr; i++) {
3539 const struct cache_entry *ce = subrepo.index->cache[i];
3540