Re: [PATCH 0/4] Sparse checkout: fix bug with worktree of bare repo
From: Eric Sunshine <hidden>
Date: 2021-12-20 16:21:12
On Mon, Dec 20, 2021 at 10:57 AM Derrick Stolee via GitGitGadget [off-list ref] wrote:
This patch series includes a fix to the bug reported by Sean Allred [1] and diagnosed by Eric Sunshine [2]. The root cause is that 'git sparse-checkout init' writes to the worktree config without checking that core.bare might need to be set. This only matters when the base repository is bare, since creating the config.worktree file and enabling extensions.worktreeConfig will cause Git to treat the base repo's core.bare=false as important for this worktree.
Thanks for jumping on this so quickly. Unfortunately, however, as mentioned in [1] and [2], I think the approach implemented here of setting `core.bare=false` in the worktree-specific config is fundamentally flawed since it only addresses the problem for worktrees in which `git sparse-checkout init` has been run, but leaves all other worktrees potentially broken (both existing and new worktrees). As far as I can see, the _only_ correct solution is for the new helper function to enable `extensions.worktreeConfig` _and_ relocate `core.bare` and `core.worktree` from .git/config to .git/worktree.config, thus implementing the requirements documented in git-worktree.txt. I also raised a separate question in [2] about whether `git sparse-checkout init` or the new helper function should be warning the user that upgrading the repository format and setting `extensions.worktreeConfig` might break third-party tools. However, that question is tangential to the fix being addressed here and doesn't need to be addressed by this series. [1]: https://lore.kernel.org/git/CAPig+cQ6U_yFw-X2OWrizB1rbCvc4bNxuSzKFzmoLNnm0GH8Eg@mail.gmail.com/ (local) [2]: https://lore.kernel.org/git/CAPig+cQPUe9REf+wgVNjyak_nk3V361h-48rTFgk6TGC7vJgOA@mail.gmail.com/ (local)