git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: Regression: submodule worktrees can clobber core.worktree config

From
Stefan Beller <sbeller@google.com>
Date
Jan 9, 2019, 17:42 UTC
Message-ID
<CAGZ79kZBwocC=UzjW+DxodwJkQZ2mNMYNjsk6sL4SCqdhGoQ7w@mail.gmail.com>
In-Reply-To
<CAG0vfyQeA3Hm7AsYgYtP4v-Yg0=rKXW0YYfg_emAwEscZha4VA@mail.gmail.com>
On Tue, Jan 8, 2019 at 2:16 PM Tomasz Śniatowski <tsniatowski@vewd.com> wrote:
Show 24 quoted lines
>
> 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 status
>
> The 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 a
>
> Looking at the config file itself, the submodule update operation applies the
> following change (the new path is invalid):
>     -       worktree = ../../../a
>     +       worktree = ../../../../../../b2/a
>
> This 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.
Thanks for reporting the issue!
>
> Bisects down to:
> 74d4731da1 submodule--helper: replace connect-gitdir-workingtree by
> ensure-core-worktree
So this would need to update the worktree config, not the generic config.
We'd need to replace the line
    cfg_file = repo_git_path(&subrepo, "config");
in builtin/submodule--helper.c::ensure_core_worktree()
to be a worktree specific call.

Or the other way round we'd want to make repo_git_path to be worktree specific and introduce repo_common_path for the main working tree.

Looking at Duys tree, https://gitlab.com/pclouds/git/commit/94751ada7c32eb6fb2c67dd7723161d1955a5683 is pretty much what we need.

Reverting that topic that introduced this (4d6d6e, Merge branch 'sb/submodule-update-in-c'), might be possible but that would conflict with another followup that fixes issues in that series (see sb/submodule-unset-core-worktree-when-worktree-is-lost https://github.com/gitster/git/commits/sb/submodule-unset-core-worktree-when-worktree-is-lost) so I'd rather just cherry-pick the commit from Duy.

Stefan
Previous: Duy NguyenNext: Tomasz Śniatowski
Message 5 of 8 in “Regression: submodule worktrees can clobber core.worktree config”
  1. Tomasz ŚniatowskiJan 8, 2019
  2. Duy NguyenJan 8, 2019
  3. Tomasz ŚniatowskiJan 9, 2019
  4. Duy NguyenJan 9, 2019
  5. Stefan BellerJan 9, 2019
  6. Tomasz ŚniatowskiJan 9, 2019
  7. Stefan BellerJan 10, 2019
  8. Duy NguyenJan 11, 2019

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.