Skip to content

Commit 7bf3057

Browse files
pks-tgitster
authored andcommitted
builtin/receive-pack: convert to use git-maintenance(1)
In 850b6ed (auto-gc: extract a reusable helper from "git fetch", 2020-05-06), we have introduced a helper function `run_auto_gc()` that kicks off `git gc --auto`. The intent of this function was to pass down the "--quiet" flag to git-gc(1) as required without duplicating this at all callsites. In 7c3e9e8 (auto-gc: pass --quiet down from am, commit, merge and rebase, 2020-05-06) we then converted callsites that need to pass down this flag to use the new helper function. This has the notable omission of git-receive-pack(1), which is the only remaining user of `git gc --auto` that sets up the proccess manually. This is probably because it unconditionally passes down the `--quiet` flag and thus didn't benefit much from the new helper function. In a95ce12 (maintenance: replace run_auto_gc(), 2020-09-17) we then replaced `run_auto_gc()` with `run_auto_maintenance()` which invokes git-maintenance(1) instead of git-gc(1). This command is the modern replacement for git-gc(1) and is both more thorough and also more flexible because administrators can configure which tasks exactly to run during maintenance. But due to git-receive-pack(1) not using `run_auto_gc()` in the first place it did not get converted to use git-maintenance(1) like we do everywhere else now. Address this oversight and start to use the newly introduced function `prepare_auto_maintenance()`. This will also make it easier for us to adapt this code together with all the other callsites that invoke auto-maintenance in the future. This removes the last internal user of `git gc --auto`. Signed-off-by: Patrick Steinhardt <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent b396ee6 commit 7bf3057

File tree

2 files changed

+11
-12
lines changed

2 files changed

+11
-12
lines changed

Documentation/config/receive.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ receive.advertisePushOptions::
88
capability to its clients. False by default.
99

1010
receive.autogc::
11-
By default, git-receive-pack will run "git-gc --auto" after
11+
By default, git-receive-pack will run "git maintenance run --auto" after
1212
receiving data from git-push and updating refs. You can stop
1313
it by setting this variable to false.
1414

builtin/receive-pack.c

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2581,17 +2581,16 @@ int cmd_receive_pack(int argc, const char **argv, const char *prefix)
25812581
if (auto_gc) {
25822582
struct child_process proc = CHILD_PROCESS_INIT;
25832583

2584-
proc.no_stdin = 1;
2585-
proc.stdout_to_stderr = 1;
2586-
proc.err = use_sideband ? -1 : 0;
2587-
proc.git_cmd = proc.close_object_store = 1;
2588-
strvec_pushl(&proc.args, "gc", "--auto", "--quiet",
2589-
NULL);
2590-
2591-
if (!start_command(&proc)) {
2592-
if (use_sideband)
2593-
copy_to_sideband(proc.err, -1, NULL);
2594-
finish_command(&proc);
2584+
if (prepare_auto_maintenance(1, &proc)) {
2585+
proc.no_stdin = 1;
2586+
proc.stdout_to_stderr = 1;
2587+
proc.err = use_sideband ? -1 : 0;
2588+
2589+
if (!start_command(&proc)) {
2590+
if (use_sideband)
2591+
copy_to_sideband(proc.err, -1, NULL);
2592+
finish_command(&proc);
2593+
}
25952594
}
25962595
}
25972596
if (auto_update_server_info)

0 commit comments

Comments
 (0)