summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDerrick Stolee <dstolee@microsoft.com>2021-04-01 01:49:54 (GMT)
committerJunio C Hamano <gitster@pobox.com>2021-04-14 20:47:32 (GMT)
commitd425f65127562e3a7f308b1ccfe385950f96e8ec (patch)
tree23dfee2e9242d8607db78fd3c4d463ccb93cbc51
parent2508df0272fdae3025b53366ac6b456920bc0de0 (diff)
downloadgit-d425f65127562e3a7f308b1ccfe385950f96e8ec.zip
git-d425f65127562e3a7f308b1ccfe385950f96e8ec.tar.gz
git-d425f65127562e3a7f308b1ccfe385950f96e8ec.tar.bz2
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>
-rw-r--r--dir.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/dir.c b/dir.c
index 5b00dfb..166238e 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];