git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Philippe Blain <levraiphilippeblain@gmail.com>
To: Atharva Raykar <raykar.ath@gmail.com>,
	Rostislav Krasny <rosti.bsd@gmail.com>
Cc: "brian m. carlson" <sandals@crustytoothpaste.net>, git@vger.kernel.org
Subject: Re: Why do submodules detach HEAD? (was Re: Incorrect and inconsistent End-Of-Line characters in .gitmodules ...)
Date: Wed, 21 Jul 2021 18:42:27 -0400	[thread overview]
Message-ID: <9d39da2c-1450-d462-5d80-13112a529c2e@gmail.com> (raw)
In-Reply-To: <46F5B91F-4DBE-4F34-9395-7CC808FAC359@gmail.com>

Hi Atharva,

Le 2021-07-21 à 03:26, Atharva Raykar a écrit :
> On 18-Jul-2021, at 02:52, Rostislav Krasny <rosti.bsd@gmail.com> 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@gmail.com/


  reply	other threads:[~2021-07-21 22:42 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-15 21:55 Incorrect and inconsistent End-Of-Line characters in .gitmodules after "git submodule set-branch --branch <branch_name>" Rostislav Krasny
2021-07-16 19:38 ` brian m. carlson
2021-07-17 21:22   ` Rostislav Krasny
2021-07-21  7:26     ` Why do submodules detach HEAD? (was Re: Incorrect and inconsistent End-Of-Line characters in .gitmodules ...) Atharva Raykar
2021-07-21 22:42       ` Philippe Blain [this message]
2021-08-05 13:59       ` Rostislav Krasny
2021-08-05 18:38         ` Atharva Raykar
2021-07-17 17:05 ` Incorrect and inconsistent End-Of-Line characters in .gitmodules after "git submodule set-branch --branch <branch_name>" Torsten =?unknown-8bit?Q?B=C3=B6gershausen?=
2021-07-17 22:42   ` Rostislav Krasny
2021-07-18  5:32     ` Torsten =?unknown-8bit?Q?B=C3=B6gershausen?=

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=9d39da2c-1450-d462-5d80-13112a529c2e@gmail.com \
    --to=levraiphilippeblain@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=raykar.ath@gmail.com \
    --cc=rosti.bsd@gmail.com \
    --cc=sandals@crustytoothpaste.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).