]> git.ipfire.org Git - thirdparty/git.git/commitdiff
dir: ensure full index
authorDerrick Stolee <dstolee@microsoft.com>
Thu, 1 Apr 2021 01:49:54 +0000 (01:49 +0000)
committerJunio C Hamano <gitster@pobox.com>
Wed, 14 Apr 2021 20:47:32 +0000 (13:47 -0700)
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>
dir.c

diff --git a/dir.c b/dir.c
index 5b00dfb5b1442c2de11cda83b2401d17a9fcc4fe..166238e79f52773aa69e2c252ea0e8633e9c9aa2 100644 (file)
--- 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];