diff mbox series

[v10,08/12] merge-index: stop calling ensure_full_index() twice

Message ID patch-v10-08.12-45cf7995448-20221215T084803Z-avarab@gmail.com (mailing list archive)
State New, archived
Headers show
Series merge-index: prepare to rewrite merge drivers in C | expand

Commit Message

Ævar Arnfjörð Bjarmason Dec. 15, 2022, 8:52 a.m. UTC
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@gmail.com>
---
 builtin/merge-index.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
diff mbox series

Patch

diff --git a/builtin/merge-index.c b/builtin/merge-index.c
index 4d91e7ea122..cd160779cbf 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 < the_index.cache_nr; i++) {
 		const struct cache_entry *ce = the_index.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