run-command: introduce function to prepare auto-maintenance process

The `run_auto_maintenance()` function is responsible for spawning a new
`git maintenance run --auto` process. To do so, it sets up the `sturct
child_process` and then runs it by executing `run_command()` directly.
This is rather inflexible in case callers want to modify the child
process somewhat, e.g. to redirect stderr or stdout.

Introduce a new `prepare_auto_maintenance()` function to plug this gap.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Patrick Steinhardt
2024-04-17 08:16:31 +02:00
committed by Junio C Hamano
parent 3c2a3fdc38
commit b396ee6bed
2 changed files with 20 additions and 6 deletions

View File

@ -217,6 +217,13 @@ int finish_command_in_signal(struct child_process *);
*/
int run_command(struct child_process *);
/*
* Prepare a `struct child_process` to run auto-maintenance. Returns 1 if the
* process has been prepared and is ready to run, or 0 in case auto-maintenance
* should be skipped.
*/
int prepare_auto_maintenance(int quiet, struct child_process *maint);
/*
* Trigger an auto-gc
*/