]> git.ipfire.org Git - thirdparty/git.git/commitdiff
read-cache.c: refactor set_new_index_sparsity() for subsequent commit
authorÆvar Arnfjörð Bjarmason <avarab@gmail.com>
Thu, 12 Jan 2023 12:55:26 +0000 (13:55 +0100)
committerJunio C Hamano <gitster@pobox.com>
Fri, 13 Jan 2023 18:36:58 +0000 (10:36 -0800)
Refactor code added to set_new_index_sparsity() in [1] to eliminate
indentation resulting from putting the body of his function within the
"if" block. Let's instead return early if we have no
istate->repo. This trivial change makes the subsequent commit's diff
smaller.

1. 491df5f679f (read-cache: set sparsity when index is new, 2022-05-10)

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Acked-by: Derrick Stolee <derrickstolee@github.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
read-cache.c

index 1ff518b2a7f8cd3b383d86e1917bed4debc432b4..1782e940353c3366e621dc94bdacabe3b0d91bb8 100644 (file)
@@ -2292,12 +2292,12 @@ static void set_new_index_sparsity(struct index_state *istate)
         * If the index's repo exists, mark it sparse according to
         * repo settings.
         */
-       if (istate->repo) {
-               prepare_repo_settings(istate->repo);
-               if (!istate->repo->settings.command_requires_full_index &&
-                   is_sparse_index_allowed(istate, 0))
-                       istate->sparse_index = 1;
-       }
+       if (!istate->repo)
+               return;
+       prepare_repo_settings(istate->repo);
+       if (!istate->repo->settings.command_requires_full_index &&
+           is_sparse_index_allowed(istate, 0))
+               istate->sparse_index = 1;
 }
 
 /* remember to discard_cache() before reading a different cache! */