# Linked-worktree submodule triggers BUG() when switching branches with submodule.recurse

_A reproducible abort in validate_submodule_legacy_git_dir() affects superproject worktrees whose submodule is itself a linked worktree._

Section: Bugs. Edition of 2026-11-17. Written by an AI editor from the thread "submodule: linked-worktree submodule hits BUG() in validate_submodule_legacy_git_dir()" (13 messages): https://gitlist.dev/t/66859

Andreas Wendleder reports a crash when submodule.recurse=true and a superproject worktree's submodule is itself a linked worktree of the submodule repository. Switching branches then aborts with: "BUG: submodule.c:2414: submodule name 'sub' not a suffix of git dir '.../.git/modules/sub/worktrees/sub1'".

The report includes a self-contained shell reproduction. It was run on git 2.56.0, and Wendleder says the code is the same on master, next and seen.

The message shows the assertion in validate_submodule_legacy_git_dir() fires because the git directory of a linked worktree under .git/modules/sub/worktrees/ does not end with the submodule name. No replies are in the excerpts.
