[PATCH 12/27] ls-files: ensure full index
- From
Derrick Stolee via GitGitGadget <gitgitgadget@gmail.com>
- Date
- Mar 16, 2021, 21:17 UTC
- Message-ID
- <00c8a7e1d119fa3b403227eb415200bba01f4bda.1615929436.git.gitgitgadget@gmail.com>
- In-Reply-To
- <pull.906.git.1615929435.gitgitgadget@gmail.com>
From: Derrick Stolee <dstolee@microsoft.com>
Before iterating over all cache entries, ensure that a sparse index is expanded to a full one to avoid missing files.
Signed-off-by: Derrick Stolee <dstolee@microsoft.com> --- builtin/ls-files.c | 2 ++ 1 file changed, 2 insertions(+)
diff --git a/builtin/ls-files.c b/builtin/ls-files.c index 76a0d35c1a01..8fbef2b14f29 100644 --- a/builtin/ls-files.c +++ b/builtin/ls-files.c @@ -317,6 +317,7 @@ static void show_files(struct repository *repo, struct dir_struct *dir) if (!(show_cached || show_stage || show_deleted || show_modified)) return; + ensure_full_index(repo->index); for (i = 0; i < repo->index->cache_nr; i++) { const struct cache_entry *ce = repo->index->cache[i]; struct stat st; @@ -495,6 +496,7 @@ void overlay_tree_on_index(struct index_state *istate, die("bad tree-ish %s", tree_name); /* Hoist the unmerged entries up to stage #3 to make room */ + ensure_full_index(istate); for (i = 0; i < istate->cache_nr; i++) { struct cache_entry *ce = istate->cache[i]; if (!ce_stage(ce))
-- gitgitgadget