Re: [PATCH v2 6/8] maintenance: add ability to pass config options
- From
Ævar Arnfjörð Bjarmason <avarab@gmail.com>
- Date
- Feb 25, 2022, 10:29 UTC
- Message-ID
- <220225.86tucn8ch4.gmgdl@evledraar.gmail.com>
- In-Reply-To
- <cfa6dca8ef4a64b6233e3b7b6021571447fc5ba9.1645719218.git.gitgitgadget@gmail.com>
On Thu, Feb 24 2022, Robert Coup via GitGitGadget wrote:
Show 42 quoted lines
> From: Robert Coup <robert@coup.net.nz>
>
> Make run_auto_maintenance() accept optional config options for a
> specific invocation of the auto-maintenance process.
> [...]
> -int run_auto_maintenance(int quiet)
> +int run_auto_maintenance(int quiet, const struct strvec *config_opts)
> {
> int enabled;
> + int i;
> struct child_process maint = CHILD_PROCESS_INIT;
>
> if (!git_config_get_bool("maintenance.auto", &enabled) &&
> @@ -1809,6 +1810,11 @@ int run_auto_maintenance(int quiet)
>
> maint.git_cmd = 1;
> maint.close_object_store = 1;
> +
> + if (config_opts)
> + for (i = 0; i<config_opts->nr; i++)
> + strvec_pushl(&maint.args, "-c", config_opts->v[i], NULL);
> +
> strvec_pushl(&maint.args, "maintenance", "run", "--auto", NULL);
> strvec_push(&maint.args, quiet ? "--quiet" : "--no-quiet");
>
> diff --git a/run-command.h b/run-command.h
> index 07bed6c31b4..24021abd41f 100644
> --- a/run-command.h
> +++ b/run-command.h
> @@ -222,8 +222,11 @@ int run_command(struct child_process *);
>
> /*
> * Trigger an auto-gc
> + *
> + * config_opts is an optional list of additional config options to
> + * pass to the maintenance process in the form "some.option=value".
> */
> -int run_auto_maintenance(int quiet);
> +int run_auto_maintenance(int quiet, const struct strvec *config_opts);
>
> #define RUN_COMMAND_NO_STDIN (1<<0)
> #define RUN_GIT_CMD (1<<1)Shouldn't this bei using git grep the git_config_push.*parameter() functions instead of adding a new custom method to do this.
Perhaps there's some subtle distinction between the two that's important here, or perhaps you just didn't know about that API...