Git development
 help / color / mirror / Atom feed
From: Andreas Wendleder <gonsolo@gmail.com>
To: git@vger.kernel.org
Cc: Adrian Ratiu <adrian.ratiu@collabora.com>,
	Phillip Wood <phillip.wood123@gmail.com>
Subject: submodule: linked-worktree submodule hits BUG() in validate_submodule_legacy_git_dir()
Date: Mon, 16 Nov 2026 23:51:48 +0100	[thread overview]
Message-ID: <avuJBGlB3pRU3JU0@pampelmuse> (raw)

With submodule.recurse=true, switching branches in a superproject worktree
whose submodule is itself a linked worktree of the submodule repository
aborts:

  BUG: submodule.c:2414: submodule name 'sub' not a suffix of git dir
  '.../.git/modules/sub/worktrees/sub1'

Reproduction (git 2.56.0; the code is the same on master, next and seen):

  #!/bin/sh
  set -e
  export GIT_CONFIG_GLOBAL=/dev/null GIT_CONFIG_NOSYSTEM=1
  g() { git -c user.name=t -c user.email=t@t -c protocol.file.allow=always "$@"; }
  rm -rf w && mkdir w && cd w
  g init -q -b main sub && g -C sub commit -q --allow-empty -m s1
  g init -q -b main super && cd super
  g submodule add -q ../sub sub && g commit -q -m add
  g -C sub commit -q --allow-empty -m s2 && g add sub && g commit -q -m bump
  g branch other HEAD~1
  g worktree add -q --detach ../wt main
  g -C sub worktree add -q --detach ../../other/sub HEAD  # takes the name 'sub'
  g -C sub worktree add -q --detach ../../wt/sub HEAD     # so this one is 'sub1'
  cd ../wt
  g -c submodule.recurse=true switch other

submodule_move_head() expects validate_submodule_git_dir() to return < 0
and then dies with "refusing to create/use ... Enabling
extensions.submodulePathConfig should fix this", but without the extension
validate_submodule_legacy_git_dir() calls BUG() instead. A linked
worktree's git dir (modules/<name>/worktrees/<id>) never ends in the
submodule name, so this setup always hits it.

With extensions.submodulePathConfig enabled (repositoryformatversion 1),
the same commands no longer crash but die with the "refusing to create/use
..." message, which recommends enabling the extension that is already
enabled.

I would expect a linked worktree of a submodule's repository to be
accepted as the submodule's git dir. If it is meant to be rejected, the
legacy path should return an error instead of calling BUG(), and the hint
should not suggest the extension when it is already on.

             reply	other threads:[~2026-11-16 22:51 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-16 22:51 Andreas Wendleder [this message]
2026-11-17 17:45 ` submodule: linked-worktree submodule hits BUG() in validate_submodule_legacy_git_dir() Adrian Ratiu

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=avuJBGlB3pRU3JU0@pampelmuse \
    --to=gonsolo@gmail.com \
    --cc=adrian.ratiu@collabora.com \
    --cc=git@vger.kernel.org \
    --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