Skip to content

Commit 5a22a33

Browse files
dschogitster
authored andcommitted
run_auto_maintenance(): implicitly close the object store
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 <[email protected]> Signed-off-by: Johannes Schindelin <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 28d04e1 commit 5a22a33

File tree

5 files changed

+1
-5
lines changed

5 files changed

+1
-5
lines changed

builtin/am.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1848,7 +1848,6 @@ static void am_run(struct am_state *state, int resume)
18481848
*/
18491849
if (!state->rebasing) {
18501850
am_destroy(state);
1851-
close_object_store(the_repository->objects);
18521851
run_auto_maintenance(state->quiet);
18531852
}
18541853
}

builtin/fetch.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2133,8 +2133,6 @@ int cmd_fetch(int argc, const char **argv, const char *prefix)
21332133
NULL);
21342134
}
21352135

2136-
close_object_store(the_repository->objects);
2137-
21382136
if (enable_auto_gc)
21392137
run_auto_maintenance(verbosity < 0);
21402138

builtin/merge.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -469,7 +469,6 @@ static void finish(struct commit *head_commit,
469469
* We ignore errors in 'gc --auto', since the
470470
* user should see them.
471471
*/
472-
close_object_store(the_repository->objects);
473472
run_auto_maintenance(verbosity < 0);
474473
}
475474
}

builtin/rebase.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -740,7 +740,6 @@ static int finish_rebase(struct rebase_options *opts)
740740
delete_ref(NULL, "REBASE_HEAD", NULL, REF_NO_DEREF);
741741
unlink(git_path_auto_merge(the_repository));
742742
apply_autostash(state_dir_path("autostash", opts));
743-
close_object_store(the_repository->objects);
744743
/*
745744
* We ignore errors in 'git maintenance run --auto', since the
746745
* user should see them.

run-command.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1891,6 +1891,7 @@ int run_auto_maintenance(int quiet)
18911891
return 0;
18921892

18931893
maint.git_cmd = 1;
1894+
maint.close_object_store = 1;
18941895
strvec_pushl(&maint.args, "maintenance", "run", "--auto", NULL);
18951896
strvec_push(&maint.args, quiet ? "--quiet" : "--no-quiet");
18961897

0 commit comments

Comments
 (0)