Web lists-archives.com

Re: [PATCH 1/3] submodule.c: add has_submodules to check if we have any submodules




On Wed, May 17, 2017 at 10:38 PM, Junio C Hamano <gitster@xxxxxxxxx> wrote:
> Stefan Beller <sbeller@xxxxxxxxxx> writes:
>
>> diff --git a/builtin/fetch.c b/builtin/fetch.c
>> index 4ef7a08afc..510ef1c9de 100644
>> --- a/builtin/fetch.c
>> +++ b/builtin/fetch.c
>> @@ -1344,7 +1344,7 @@ int cmd_fetch(int argc, const char **argv, const char *prefix)
>>                       set_config_fetch_recurse_submodules(arg);
>>               }
>>               gitmodules_config();
>> -             git_config(submodule_config, NULL);
>> +             load_submodule_config();
>>       }
>>
>> ...
>> +static enum {
>> +     SUBMODULE_CONFIG_NOT_READ = 0,
>> +     SUBMODULE_CONFIG_NO_CONFIG,
>> +     SUBMODULE_CONFIG_EXISTS,
>> +} submodule_config_reading;
>> +
>>  /*
>>   * The following flag is set if the .gitmodules file is unmerged. We then
>>   * disable recursion for all submodules where .git/config doesn't have a
>> @@ -83,6 +89,62 @@ int update_path_in_gitmodules(const char *oldpath, const char *newpath)
>>       return 0;
>>  }
>>
>> +static int submodule_config(const char *var, const char *value, void *cb)
>> +{
>> +     if (!strcmp(var, "submodule.fetchjobs")) {
>> +...
>> +     }
>> +     return 0;
>> +}
>> +
>> +void load_submodule_config(void)
>> +{
>> +     submodule_config_reading = SUBMODULE_CONFIG_NO_CONFIG;
>> +     git_config(submodule_config, NULL);
>> +}
>
> OK, so anybody who does the git_config(submodule_config) must
> instead call this one, so that we can notice there is some
> "submodule" stuff configured.  And that is ensured by making
> submodule_config private to this module.

Exactly.

> Nicely done.

Thanks.

>
> On a possibly related tangent, I've often found it somewhat
> irritating that that these two calls have to go hand-in-hand.
>
>>               gitmodules_config();
>> -             git_config(submodule_config, NULL);
>
> I wonder if it makes sense to roll that gitmodule_config() thing
> into this function as well?

This patch has been sitting on my hard drive for quite a while
and I just vaguely remember that I did not do that for some
complication along the way. I'll re-examine the situation.

Thanks,
Stefan