summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDerrick Stolee <dstolee@microsoft.com>2021-04-01 01:49:49 (GMT)
committerJunio C Hamano <gitster@pobox.com>2021-04-14 20:47:17 (GMT)
commit42f44e84eb3be06f463ebc33baa2fc91423f4470 (patch)
tree48701c0e2b52f76a3b581c4104f3fa6e4c847352
parent46eb6e31ef01684ec2dc64f690a63446022940e5 (diff)
downloadgit-42f44e84eb3be06f463ebc33baa2fc91423f4470.zip
git-42f44e84eb3be06f463ebc33baa2fc91423f4470.tar.gz
git-42f44e84eb3be06f463ebc33baa2fc91423f4470.tar.bz2
ls-files: ensure full index
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> Reviewed-by: Elijah Newren <newren@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
-rw-r--r--builtin/ls-files.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/builtin/ls-files.c b/builtin/ls-files.c
index 4f9ed1f..a0b4e54 100644
--- a/builtin/ls-files.c
+++ b/builtin/ls-files.c
@@ -317,6 +317,8 @@ static void show_files(struct repository *repo, struct dir_struct *dir)
if (!(show_cached || show_stage || show_deleted || show_modified))
return;
+ /* TODO: audit for interaction with sparse-index. */
+ 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;
@@ -494,6 +496,8 @@ 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 */
+ /* TODO: audit for interaction with sparse-index. */
+ ensure_full_index(istate);
for (i = 0; i < istate->cache_nr; i++) {
struct cache_entry *ce = istate->cache[i];
if (!ce_stage(ce))