Fix git worktree popup popup no worktree when opened in a project (#55053) (cherry-pick to preview)#55790
Merged
maxbrunsfeld merged 1 commit intov1.1.xfrom May 5, 2026
Merged
Conversation
…5053) ## Summary Fixes the `git: worktree` popup showing no worktrees when a project is opened at the parent of a `.bare` directory (the common bare-clone-with-sibling-worktrees layout). ## What's fixed - `crates/git/src/repository.rs` - New `git_binary_for_worktree_list` helper that uses `repository.path()` as the working directory when `workdir()` is `None`. - `worktrees()` switched to the new helper. - `parse_worktrees_from_str` accepts bare entries without a `HEAD` line. - Tests - Unit test: parser handles a bare entry with no `HEAD` followed by a normal worktree entry. - Integration test: full `.git`-file → `.bare` + sibling worktrees layout (`main`, `feature-a`, `feature-b`) is listed correctly via the real `git` binary. UI rendering already gates on empty sha (`worktree_picker.rs` uses `.when(!sha.is_empty(), ...)`), so the bare entry's empty sha renders without artifacts. ## Self-Review Checklist: - [x] I've reviewed my own diff for quality, security, and reliability - [x] Unsafe blocks (if any) have justifying comments — N/A, no `unsafe` - [x] The content is consistent with the [UI/UX checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist) - [x] Tests cover the new/changed behavior - [x] Performance impact has been considered and is acceptable — same single `git worktree list --porcelain` invocation, no extra work #### Closes #54824 Video [Screencast from 2026-04-28 09-43-45.webm](https://github.com/user-attachments/assets/e414d546-eb61-4cb2-857e-3c392f416f96) Release Notes: - Fixed the `git: worktree` popup listing no worktrees when a project was opened at the parent of a `.bare` directory (bare-clone-with-sibling-worktrees layout). --------- Co-authored-by: Max Brunsfeld <maxbrunsfeld@gmail.com>
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.
Cherry-pick of #55053 to preview
Summary
Fixes the
git: worktreepopup showing no worktrees when a project isopened at the parent of a
.baredirectory (the commonbare-clone-with-sibling-worktrees layout).
What's fixed
crates/git/src/repository.rsNew
git_binary_for_worktree_listhelper that usesrepository.path()as the working directory whenworkdir()isNone.worktrees()switched to the new helper.parse_worktrees_from_straccepts bare entries without aHEADline.Tests
Unit test: parser handles a bare entry with no
HEADfollowed by anormal worktree entry.
Integration test: full
.git-file →.bare+ sibling worktreeslayout (
main,feature-a,feature-b) is listed correctly via thereal
gitbinary.UI rendering already gates on empty sha (
worktree_picker.rsuses.when(!sha.is_empty(), ...)), so the bare entry's empty sha renderswithout artifacts.
Self-Review Checklist:
unsafechecklist
single
git worktree list --porcelaininvocation, no extra workCloses #54824
Video
Screencast.from.2026-04-28.09-43-45.webm
Release Notes:
git: worktreepopup listing no worktrees when a projectwas opened at the parent of a
.baredirectory(bare-clone-with-sibling-worktrees layout).
Co-authored-by: Max Brunsfeld maxbrunsfeld@gmail.com