Re: [PATCH v2 7/7] run-command: fix detaching when running auto maintenance

Junio C Hamano
2024-08-15T16:13:32Z

Patrick Steinhardt <ps@pks.im> writes:

> diff --git a/run-command.c b/run-command.c
> index 45ba544932..94f2f3079f 100644
> --- a/run-command.c
> +++ b/run-command.c
> @@ -1808,16 +1808,26 @@ void run_processes_parallel(const struct run_process_parallel_opts *opts)
>
> int prepare_auto_maintenance(int quiet, struct child_process *maint)
> {
> - int enabled;
> + int enabled, auto_detach;
>
> if (!git_config_get_bool("maintenance.auto", &enabled) &&
> !enabled)
> return 0;
>
> + /*
> + * When `maintenance.autoDetach` isn't set, then we fall back to
> + * honoring `gc.autoDetach`. This is somewhat weird, but required to
> + * retain behaviour from when we used to run git-gc(1) here.
> + */
> + if (git_config_get_bool("maintenance.autodetach", &auto_detach) &&
> + git_config_get_bool("gc.autodetach", &auto_detach))
> + auto_detach = 1;

I think this needs somehow documented. Something like this,
perhaps?

Documentation/config/gc.txt | 2 ++
Documentation/config/maintenance.txt | 9 +++++++++
2 files changed, 11 insertions(+)

diff --git c/Documentation/config/gc.txt w/Documentation/config/gc.txt
index 664a3c2874..6506ccb87f 100644
--- c/Documentation/config/gc.txt
+++ w/Documentation/config/gc.txt
@@ -41,6 +41,8 @@ use, it'll affect how the auto pack limit works.
gc.autoDetach::
Make `git gc --auto` return immediately and run in the background
if the system supports it. Default is true.
+ It also acts as a fallback setting for the `maintenance.autoDetach`
+ configuration variable.

gc.bigPackThreshold::
If non-zero, all non-cruft packs larger than this limit are kept
diff --git c/Documentation/config/maintenance.txt w/Documentation/config/maintenance.txt
index 69a4f05153..7a481a494a 100644
--- c/Documentation/config/maintenance.txt
+++ w/Documentation/config/maintenance.txt
@@ -3,6 +3,15 @@ maintenance.auto::
`git maintenance run --auto` after doing their normal work. Defaults
to true.

+maintenance.autoDetach::
+ Tasks that are run via `git maintenance run --auto` by
+ default runs in the background, if the system supports it.
+ Setting this configuration variable to `true` explicitly
+ asks them to run in the background, and setting it to
+ `false` forces them to run in the foreground. If this
+ variable is not set, `gc.autoDetach` works as a fallback
+ variable and behaves the same way.
+
maintenance.strategy::
This string config option provides a way to specify one of a few
recommended schedules for background maintenance. This only affects