Regression: submodule worktrees can clobber core.worktree config
- From
- Tomasz Śniatowski <tsniatowski@vewd.com>
- Date
- Jan 8, 2019, 22:16 UTC
- Message-ID
- <CAG0vfyQeA3Hm7AsYgYtP4v-Yg0=rKXW0YYfg_emAwEscZha4VA@mail.gmail.com>
After upgrading to 2.20.1 I noticed in some submodule+worktree scenarios git
will break the submodule configuration. Reproducible with:
git init a && (cd a; touch a; git add a; git commit -ma)
git init b && (cd b; git submodule add ../a; git commit -mb)
git -C b worktree add ../b2
git -C b/a worktree add ../../b2/a
git -C b status
git -C b2 submodule update
git -C b statusThe submodule update in the _worktree_ puts an invalid core.worktree value in
the _original_ repository submodule config (b/.git/modules/a/config), causing
the last git status to error out with:
fatal: cannot chdir to '../../../../../../b2/a': No such file or directory
fatal: 'git status --porcelain=2' failed in submodule aLooking at the config file itself, the submodule update operation applies the
following change (the new path is invalid):
- worktree = ../../../a
+ worktree = ../../../../../../b2/aThis worked fine on 2.19.2 (no config change, no error), and was useful to have a worktree with (large) submodules that are also worktrees.
Bisects down to: 74d4731da1 submodule--helper: replace connect-gitdir-workingtree by ensure-core-worktree
-- Tomasz Śniatowski