Subject: Re: [PATCH v2 6/8] maintenance: add ability to pass config options

From: Ævar Arnfjörð Bjarmason <[email-masked]>
Date: Fri, 25 Feb 2022 11:29:51 +0100

On Thu, Feb 24 2022, Robert Coup via GitGitGadget wrote:

> From: Robert Coup <[email-masked]>
>
> 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...