From: Junio C Hamano <gitster@pobox.com>
To: Phillip Wood <phillip.wood123@gmail.com>
Cc: JAM <kratsbinovish@gmail.com>, git@vger.kernel.org
Subject: Re: [RFC] worktree: add --recurse-submodules support to git worktree add
Date: Wed, 15 Apr 2026 09:23:27 -0700 [thread overview]
Message-ID: <xmqq1pgg8a68.fsf@gitster.g> (raw)
In-Reply-To: <823d30b3-b355-430b-b8af-c8421a87b0aa@gmail.com> (Phillip Wood's message of "Wed, 15 Apr 2026 15:05:07 +0100")
Phillip Wood <phillip.wood123@gmail.com> writes:
> On 15/04/2026 01:14, JAM wrote:
>> Back in 2022, Glen Choo noted [1] that git worktree add leaves submodules
>> unhandled and suggested a --recurse-submodules flag to fix that. The thread
>> went quiet. The 2015–2016 discussions by Duy and Beller [2][3] had flagged a
>> deeper design concern: submodule existence (which worktrees have which
>> submodules checked out) is tangled up with submodule configuration (URL,
>> path),
>> making per-worktree submodule support tricky to reason about.
>>
>> This proposal sidesteps that concern entirely. Rather than touching
>> submodule
>> configuration at all, the idea is to reuse the git object data that's
>> already
>> present in the main repository — the same thing git worktree add already
>> does
>> for the top-level object store, extended down to the submodule layer.
>
> I'm not really a submodule user so maybe I'm missing something.
> Worktrees separate out per-worktree data such as refs like HEAD which
> are stored under the worktree's gitdir in
> "$GIT_COMMON_DIR/worktrees/$id" and per-repository data such as the
> object store which is stored under "$GIT_COMMON_DIR". The proposal below
> appears to use the same modules directory for each worktree so if I have
> two worktrees A and B each with a submodule "sub" how can I checkout
> commit C1 in "A/sub" and commit C2 in "B/sub" when they share the same
> gitdir? It makes sense for "A/sub" and "B/sub" to share the same object
> database, but they don't want to share the same HEAD.
True. I am not a submodule user and do not have a strong interest
in submodules, but I agree that once the superproject wants to use
multiple worktrees, the submodules bound to it inevitably need to
use different worktrees that correspond to the worktrees used by the
superproject exactly because of the point you raise here. They need
to be able to independently check out a suitable commit in the
context of the superproject's worktree that is checked out.
next prev parent reply other threads:[~2026-04-15 16:23 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-15 0:14 [RFC] worktree: add --recurse-submodules support to git worktree add JAM
2026-04-15 14:05 ` Phillip Wood
2026-04-15 16:23 ` Junio C Hamano [this message]
-- strict thread matches above, loose matches on Subject: below --
2026-04-15 15:12 Jimmy Aguilar Mena
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=xmqq1pgg8a68.fsf@gitster.g \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
--cc=kratsbinovish@gmail.com \
--cc=phillip.wood123@gmail.com \
/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.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox