git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Rostislav Krasny <rosti.bsd@gmail.com>
To: Atharva Raykar <raykar.ath@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: Thu, 5 Aug 2021 16:59:54 +0300	[thread overview]
Message-ID: <CANt7McE4N0wv5bik8tSNrdTs-mcL20cJPMP42iPtZqhUpKgirA@mail.gmail.com> (raw)
In-Reply-To: <46F5B91F-4DBE-4F34-9395-7CC808FAC359@gmail.com>

On Wed, Jul 21, 2021 at 10:26 AM Atharva Raykar <raykar.ath@gmail.com> wrote:
> The default mode for the update command is to checkout to the
> revision that the parent project expects the submodule to be in, ie,
> it checks out to the commit hash directly, and detaches the HEAD.
>
> Why not checkout to a branch? This is because branches may change
> which commits they point to.
>
> For example, if you had a submodule 'foo'. I go into the 'foo'
> folder and amend the last commit.
>
> Now if I run 'submodule update' in the parent repository. If it had
> checked out to the branch instead of the revision, I would be on a
> different commit in 'foo' than the one that was registered by the
> parent repo!
>
> We want to have idempotence, ie, for a particular revision that is
> registered by our parent project, we want 'update' to give the same
> outcome every time, and not be dependent on whatever the state of the
> branch is. This way we ensure that for a particular commit in the
> parent project, the submodules will be in the same state for every
> system in the world, after an 'update' is run.

All this is ok, but there could be other uses of sub-modules. Why not
to make this behavior configurable?

As a developer I may want to make new commits on those sub-modules and
always work with latest versions of their particular branches. In the
detached HEAD mode this is much harder to be done and also an error
prone operation. Commits that are done in the detached HEAD state may
easily be lost. Google is full of questions about how this could be
done, i.e. there is an essential demand of such a new behavior.

  parent reply	other threads:[~2021-08-05 14:00 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
2021-08-05 13:59       ` Rostislav Krasny [this message]
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=CANt7McE4N0wv5bik8tSNrdTs-mcL20cJPMP42iPtZqhUpKgirA@mail.gmail.com \
    --to=rosti.bsd@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=raykar.ath@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).