Fix bare worktree identity in worktree switcher#55044
Open
saberoueslati wants to merge 1 commit intozed-industries:mainfrom
Open
Fix bare worktree identity in worktree switcher#55044saberoueslati wants to merge 1 commit intozed-industries:mainfrom
saberoueslati wants to merge 1 commit intozed-industries:mainfrom
Conversation
5 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Context
This fixes #54830, where switching to an existing git worktree in a bare shared-dir layout caused Zed to treat the linked worktree directory as the project root. In a layout like
monty/.bare,monty/main, andmonty/feature-a, the repository metadata fell back to the linked checkout path becauseoriginal_repo_path_from_common_dironly recognized.gitcommon dirs. That made the title bar show the project asfeature-aand the worktree label asmain.The fix teaches
original_repo_path(...)to recognize linked worktrees whose shared git dir is bare and stored undercommon_dir/worktrees/.... In that case, it now resolves the original repo path tocommon_dir.parent(), which matches howWorktreeStorealready groups these worktrees. I also added targeted regression coverage for both the path resolution helper and the bare-layout project scan path.Closes #54830
Video of the manual test below :
Screencast.from.2026-04-28.01-31-39.webm
How to Review
crates/git/src/repository.rs: Updates original repo path resolution so linked worktrees backed by a bare shared git dir resolve to the shared project root instead of the linked checkout path. Adds unit coverage for normal repos, non-bare linked worktrees, bare linked worktrees, and plain bare repos.crates/project/tests/integration/project_tests.rs: Adds an integration regression test for the.bare + main + feature-alayout and verifies that scanningfeature-aproduces repository metadata rooted atmontywhile still identifying the checkout as a linked worktree.Self-Review Checklist
Release Notes:
.bareworktree layout