Re: Why do submodules detach HEAD? (was Re: Incorrect and inconsistent End-Of-Line characters in .gitmodules ...)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Atharva,

Le 2021-07-21 à 03:26, Atharva Raykar a écrit :
On 18-Jul-2021, at 02:52, Rostislav Krasny <rosti.bsd@xxxxxxxxx> wrote:


[...]
I would like to take this opportunity to ask: why cloning a repository
that contains submodules sets this repository branch to its default
(master, main, whatever) but all submodules are set into a detached
HEAD mode instead of their default branches? This is actually the
reason I started to check what happens with the .gitmodules file. What
is the point in such an inconsistent behavior? There are a lot of
questions about that in Google and it seems most of the users expect
different behavior.

Submodules are cloned along with the parent repository only when
'submodule.recurse' is set to true, which I assume is the case for
your configuration.

Correction: no, 'git clone' always needs to be given the '--recurse-submodules' (or its old
alias, '--recursive') for submodules to be cloned. It does *not* honor
'submodule.recurse' (that's documented at [1]).

Should it honor it ?
Some people think yes, but others think no (mostly people that deal with repos with a huge number
of submodules which are optional, and thus would not want *all* submodules to be cloned
even if 'submodule.recurse' is set) . This has been discussed before,
and several tries were done to change that but for now the behaviour remains.
I personnally think that marking some submodules as optional should
be something that can be tracked in '.gitmodules', and a future version of Git
would clone all *non-optional* submodules if 'submodule.recurse' is set (some think
it should do so even if it's not set.) The most recent discussion about that, I think,
it at [2].


-- 8< --

I hope that makes sense.

(Anyone more knowledgeable than me in submodules, feel free to add
to what I am saying and correct me if I made an error!)


The rest of what you wrote is perfectly clear and correct.
Keep up the good work on your GSOC project ! :)


Cheers,

Philippe.

[1] https://git-scm.com/docs/git-config#Documentation/git-config.txt-submodulerecurse
[2] https://lore.kernel.org/git/0fc5c0f7-52f7-fb36-f654-ff5223a8809b@xxxxxxxxx/




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux