git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
Stefan Beller <sbeller@google.com>
Date
May 18, 2017, 16:34 UTC
Message-ID
<CAGZ79ka3XBu-iNbvkp9yi5ovXVaAyTH9BY+M8HOj-Q6PEMB7iw@mail.gmail.com>
In-Reply-To
<xmqqshk2u3kz.fsf@gitster.mtv.corp.google.com>
On Wed, May 17, 2017 at 10:38 PM, Junio C Hamano <gitster@pobox.com> wrote:
Show 46 quoted lines
> Stefan Beller <sbeller@google.com> 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.
Show 9 quoted lines
>
> 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

Previous: Junio C HamanoNext: Brandon Williams
Message 5 of 13 in “Add option to recurse into submodules”
  1. 0/3 Add option to recurse into submodulesStefan Beller, May 17, 2017
  2. 2/3 submodule test invocation: only pass additional argumentsStefan Beller, May 17, 2017
  3. 1/3 submodule.c: add has_submodules to check if we have any submodulesStefan Beller, May 17, 2017
  4. Junio C HamanoMay 18, 2017
  5. Stefan BellerMay 18, 2017
  6. Brandon WilliamsMay 18, 2017
  7. Stefan BellerMay 18, 2017
  8. Brandon WilliamsMay 18, 2017
  9. Stefan BellerMay 18, 2017
  10. 3/3 Introduce submodule.recurse optionStefan Beller, May 17, 2017
  11. Brandon WilliamsMay 18, 2017
  12. Stefan BellerMay 18, 2017
  13. Brandon WilliamsMay 18, 2017

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.