Subject: Re: [PATCH v2 04/10] submodule--helper: convert "foreach" to its own "--super-prefix"

From: Ævar Arnfjörð Bjarmason <[email-masked]>
Date: Thu, 17 Nov 2022 19:14:54 +0100

On Mon, Nov 14 2022, Glen Choo wrote:

> Ævar Arnfjörð Bjarmason <[email-masked]> writes:
>
>> As with a preceding commit to convert "absorbgitdirs", we can convert
>> "submodule--helper foreach" to use its own "--super-prefix", instead
>> of relying on the global "--super-prefix" argument to "git"
>> itself. See that earlier commit for the rationale and background.
>>
>> Signed-off-by: Ævar Arnfjörð Bjarmason <[email-masked]>
>> ---
>>  builtin/submodule--helper.c | 15 ++++++++++-----
>>  1 file changed, 10 insertions(+), 5 deletions(-)
>>
>> diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c
>> index c4d5e029b37..989c75280af 100644
>> --- a/builtin/submodule--helper.c
>> +++ b/builtin/submodule--helper.c
>> @@ -396,7 +398,9 @@ static int module_foreach(int argc, const char **argv, const char *prefix)
>>  	struct foreach_cb info = FOREACH_CB_INIT;
>>  	struct pathspec pathspec = { 0 };
>>  	struct module_list list = MODULE_LIST_INIT;
>> +	const char *super_prefix = NULL;
>>  	struct option module_foreach_options[] = {
>> +		OPT__SUPER_PREFIX(&super_prefix),
>>  		OPT__QUIET(&info.quiet, N_("suppress output of entering each submodule command")),
>>  		OPT_BOOL(0, "recursive", &info.recursive,
>>  			 N_("recurse into nested submodules")),
>> @@ -417,6 +421,7 @@ static int module_foreach(int argc, const char **argv, const char *prefix)
>>  	info.argc = argc;
>>  	info.argv = argv;
>>  	info.prefix = prefix;
>> +	info.super_prefix = super_prefix;
>
> (Also applies to subsequent patches) Why don't we assign the super
> prefix directly to the struct's field? e.g.
>
> 		OPT__SUPER_PREFIX(&info.super_prefix),

Good point! I've done that consistently in my WIP re-roll.