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

Re: [PATCH v4] clone: update submodule.recurse in config when using --recurse-submodule

From
Philippe Blain <levraiphilippeblain@gmail.com>
Date
Aug 10, 2021, 23:04 UTC
Message-ID
<8f24d532-b021-2a96-415b-467f715cb1ec@gmail.com>
In-Reply-To
<xmqqa6lpdu4z.fsf@gitster.g>
Hi Junio,
Le 2021-08-10 à 14:36, Junio C Hamano a écrit :
Show 23 quoted lines
> Mahi Kolla <mahikolla@google.com> writes:
> 
>>> Is it possible to avoid changing the behaviour unconditionally and
>>> potentially breaking existing users by making it an opt-in feature,
>>> e.g. "git clone --recurse-submodules" would work as the current
>>> users would expect, while "git clone --recurse-submodules=sticky"
>>> would set submodule.recurse to true, or something?
>>
>> As mentioned, the `submodule.recurse=true` will only apply to active
>> submodules specified by the user. Setting this config value when the
>> user runs their initial `git clone` minimizes the number of times a
>> developer must use the `--recurse-submodule` option on other commands.
>>
>> However, this is a behavior change that may be surprising for
>> developers. To ensure a smooth rollout and easy adoption, I think
>> adding a message using an `advice.*` config setting would be useful.
> 
> It may be better than nothing, but that still is a unilateral
> behaviour change.  Can't we come up with a way to make it an opt-in
> feature?  I've already suggested to allow the "--recurse-submodules"
> option of "git clone" to take an optional parameter (e.g. "sticky")
> so that the user can request configuration variable to be set, but
> you seem to be ignoring or skirting it.  

The '--recures-submodule' option in 'git clone' already takes an optional argument, which is a pathspec and if given, only submodules matching the given pathspec will be initialized (as opposed to all submodules if the flag is given without an argument). So, it does not seem to be possible to use this flag as a way to also set 'submodule.recurse'.

When Emily (CC'ed) sent her roadmap for submodule enhancements in [1], the enhancement that Mahi is suggesting was explicitely mentioned:

> - git clone 
...
> What doesn't already work:
>
>    * --recurse-submodules should turn on submodule.recurse=true

I don't know if Mahi is part of this effort or just came up with the same idea, but in any case maybe Emily would be able to add more justification for this change.

Show 5 quoted lines
> Even though I am not
> married to the "give optional parameter to --recurse-submodules"
> design, unconditionally setting the variable, with or without advice
> or warning, is a regression we'd want to avoid.
> 

In my opinion, it would not be a regression; it would a behaviour change that would be a *vast improvement* for the majority of projects that use submodules, at least those that use non-optional submodules (which, I believe, is the vast majority of projects that use submodules, judging by what I've read on the web over the past 3 years of my interest in the subject.)

As soon as you use submodules in a non-optional way, you really *want* submodule.recurse=true, because if not:

1. 'git checkout' does not recursively check out your submodules, which probably breaks your build.
    You have to remember to always run 'git checkout --recurse-submodules' or run 'git submdule update'
    after each checkout, and teach your team to do the same.
2. 'git pull' fetches submodules commits, but does not recursively check out your submodules,
    which also probably breaks your build. You have to remember to always run 'git pull --recurse-submodules',
    or run 'git submodule update' after each pull, and also teach your team to do so.
3. If you forget to do 1. or 2., and then use 'git commit -am "some message" (as a lot
    of Git beginners unfortunately do), you regress the submodule commit, creating a lot
    of problems down the line.

These are the main reasons that I think Git should recurse by default. Setting 'submodule.recurse' also brings other niceties, like 'git grep' recursing into submodules.

If we can agree that the behaviour *should* change eventually, then at least 'git clone --recurse-submodules' could be changed *right now* to suggest setting 'submodule.recurse' using the advice API, and stating that this will be the default some day.

Even if we don't agree that the behaviour should enventually change, I think having this advice would be a strict improvement because it would help user discover the setting, which would already go a long way.

Thanks,
Philippe.
[1] https://lore.kernel.org/git/YHofmWcIAidkvJiD@google.com/
Previous: Junio C HamanoNext: Mahi Kolla
Message 21 of 46 in “clone: update submodule.recurse in config when using --recurse-submodule”
  1. 0/2 clone: update submodule.recurse in config when using --recurse-submoduleMahi Kolla via GitGitGadget, Aug 2, 2021
  2. 1/2 clone: update submodule.recurse in config when using --recurse-submoduleMahi Kolla via GitGitGadget, Aug 2, 2021
  3. 2/2 clone: update submodule.recurse in config when using --recurse-submoduleMahi Kolla via GitGitGadget, Aug 2, 2021
  4. 0/3 clone: update submodule.recurse in config when using --recurse-submoduleMahi Kolla via GitGitGadget, Aug 2, 2021
  5. 1/3 clone: update submodule.recurse in config when using --recurse-submoduleMahi Kolla via GitGitGadget, Aug 2, 2021
  6. 2/3 clone: update submodule.recurse in config when using --recurse-submoduleMahi Kolla via GitGitGadget, Aug 2, 2021
  7. 3/3 clone test: update whitespace according to style guideMahi Kolla via GitGitGadget, Aug 2, 2021
  8. 0/4 clone: update submodule.recurse in config when using --recurse-submoduleMahi Kolla via GitGitGadget, Aug 2, 2021
  9. 1/4 clone: update submodule.recurse in config when using --recurse-submoduleMahi Kolla via GitGitGadget, Aug 2, 2021
  10. Philippe BlainAug 3, 2021
  11. Mahi KollaAug 7, 2021
  12. 2/4 clone: update submodule.recurse in config when using --recurse-submoduleMahi Kolla via GitGitGadget, Aug 2, 2021
  13. 3/4 clone test: update whitespace according to style guideMahi Kolla via GitGitGadget, Aug 2, 2021
  14. 4/4 clone: update whitespace according to style guideMahi Kolla via GitGitGadget, Aug 2, 2021
  15. Philippe BlainAug 3, 2021
  16. Junio C HamanoAug 3, 2021
  17. clone: update submodule.recurse in config when using --recurse-submoduleMahi Kolla via GitGitGadget, Aug 9, 2021
  18. Junio C HamanoAug 9, 2021
  19. Mahi KollaAug 10, 2021
  20. Junio C HamanoAug 10, 2021
  21. Philippe BlainAug 10, 2021
  22. Mahi KollaAug 10, 2021
  23. Junio C HamanoAug 11, 2021
  24. clone: set submodule.recurse=true if user enables feature.experimental flagMahi Kolla via GitGitGadget, Aug 12, 2021
  25. Junio C HamanoAug 12, 2021
  26. Emily ShafferAug 12, 2021
  27. Philippe BlainAug 13, 2021
  28. Mahi KollaAug 13, 2021
  29. Junio C HamanoAug 13, 2021
  30. Junio C HamanoAug 13, 2021
  31. Junio C HamanoAug 13, 2021
  32. Emily ShafferAug 13, 2021
  33. Junio C HamanoAug 13, 2021
  34. Emily ShafferAug 13, 2021
  35. Mahi KollaAug 13, 2021
  36. Junio C HamanoAug 13, 2021
  37. Felipe ContrerasAug 13, 2021
  38. clone: set submodule.recurse=true if submodule.stickyRecursiveClone enabledMahi Kolla via GitGitGadget, Aug 14, 2021
  39. Junio C HamanoAug 14, 2021
  40. Emily ShafferAug 17, 2021
  41. Junio C HamanoAug 18, 2021
  42. fixup! clone: set submodule.recurse=true if submodule.stickyRecursiveClone enabledJunio C Hamano, Aug 18, 2021
  43. Emily ShafferAug 19, 2021
  44. Emily ShafferAug 30, 2021
  45. Junio C HamanoAug 30, 2021
  46. Philippe BlainAug 18, 2021

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.