]> git.ipfire.org Git - thirdparty/git.git/commitdiff
run_auto_maintenance(): implicitly close the object store
authorJohannes Schindelin <johannes.schindelin@gmx.de>
Thu, 9 Sep 2021 09:47:07 +0000 (09:47 +0000)
committerJunio C Hamano <gitster@pobox.com>
Thu, 9 Sep 2021 19:56:11 +0000 (12:56 -0700)
Before spawning the auto maintenance, we need to make sure that we
release all open file handles to all the `.pack` files (and MIDX files
and commit-graph files and...) so that the maintenance process has the
freedom to delete those files.

So far, we did this manually every time before calling
`run_auto_maintenance()`. With the new `close_object_store` flag, we can
do that implicitly in that function, which is more robust because future
callers won't be able to forget to close the object store.

Note: this changes behavior slightly, as we previously _always_ closed
the object store, but now we only close the object store when actually
running the auto maintenance. In practice, this should not matter (if
anything, it might speed up operations where auto maintenance is
disabled).

Suggested-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/am.c
builtin/fetch.c
builtin/merge.c
builtin/rebase.c
run-command.c

index 0c2ad96b70eef408492987a8b358887cc56dcb9c..f239e4ddde05ecad88b9b4f2c1e53d457f4b91a8 100644 (file)
@@ -1848,7 +1848,6 @@ next:
         */
        if (!state->rebasing) {
                am_destroy(state);
-               close_object_store(the_repository->objects);
                run_auto_maintenance(state->quiet);
        }
 }
index 25740c13df1bf8d569e341fe717ff322af25207c..c9ac8664e18f0cda21f462215a276fa34e7a28ed 100644 (file)
@@ -2133,8 +2133,6 @@ int cmd_fetch(int argc, const char **argv, const char *prefix)
                                             NULL);
        }
 
-       close_object_store(the_repository->objects);
-
        if (enable_auto_gc)
                run_auto_maintenance(verbosity < 0);
 
index 22f23990b37b6af8756daa5bcf7a1a7bbef2049c..e4994e369af3010a3fd2bc7aba90d9373cc746a1 100644 (file)
@@ -469,7 +469,6 @@ static void finish(struct commit *head_commit,
                         * We ignore errors in 'gc --auto', since the
                         * user should see them.
                         */
-                       close_object_store(the_repository->objects);
                        run_auto_maintenance(verbosity < 0);
                }
        }
index 33e09619005b2aa706ffb33c0f31f2378eba1fe7..ba09ebb9e66dc0e78e13dd6071a92a76f957454f 100644 (file)
@@ -740,7 +740,6 @@ static int finish_rebase(struct rebase_options *opts)
        delete_ref(NULL, "REBASE_HEAD", NULL, REF_NO_DEREF);
        unlink(git_path_auto_merge(the_repository));
        apply_autostash(state_dir_path("autostash", opts));
-       close_object_store(the_repository->objects);
        /*
         * We ignore errors in 'git maintenance run --auto', since the
         * user should see them.
index e2dc62437745becd6046282d0c10b2d459c7b7cd..229bdff9971adce19245d0dacf3d9e1f01ffdda3 100644 (file)
@@ -1891,6 +1891,7 @@ int run_auto_maintenance(int quiet)
                return 0;
 
        maint.git_cmd = 1;
+       maint.close_object_store = 1;
        strvec_pushl(&maint.args, "maintenance", "run", "--auto", NULL);
        strvec_push(&maint.args, quiet ? "--quiet" : "--no-quiet");