When most of the ensure_full_index() calls were added in 8e97852919f (Merge branch 'ds/sparse-index-protections', 2021-04-30) we could add them at the start of cmd_*() for built-ins, but in some cases we couldn't do that, as we'd only want to initialize the index conditionally on some branches in the code. But this code added in 299e2c4561b (merge-index: ensure full index, 2021-04-01) (part of 8e97852919f) isn't such a case. The merge_all() function is only called by cmd_merge_index(), which before calling it will have called ensure_full_index() unconditionally. We can therefore skip this. While we're at it, and mainly so that we'll see the relevant code in the context, let's fix a minor whitespace issue that the addition of the ensure_full_index() call in 299e2c4561b introduced. Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@xxxxxxxxx> --- builtin/merge-index.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/builtin/merge-index.c b/builtin/merge-index.c index ee48587a8fb..9bffcc5b0f1 100644 --- a/builtin/merge-index.c +++ b/builtin/merge-index.c @@ -61,8 +61,7 @@ static void merge_one_path(const char *path) static void merge_all(void) { int i; - /* TODO: audit for interaction with sparse-index. */ - ensure_full_index(&the_index); + for (i = 0; i < active_nr; i++) { const struct cache_entry *ce = active_cache[i]; if (!ce_stage(ce)) @@ -122,7 +121,6 @@ int cmd_merge_index(int argc, const char **argv, const char *prefix) /* TODO: audit for interaction with sparse-index. */ ensure_full_index(&the_index); - if (all) merge_all(); else -- 2.38.0.1511.gcdcff1f1dc2