# Fix git worktree popup popup no worktree when opened in a project \(\#55053\) · gitcafe/zed

[View on GitCafe](https://git.cafe/gitcafe/zed/commit/358d88d02f0176217281e80744807b89e2ad674c)

Repository: [gitcafe/zed](https://git.cafe/gitcafe/zed)

Visibility: public

Requested revision: 358d88d02f0176217281e80744807b89e2ad674c

Requested commit: 358d88d02f0176217281e80744807b89e2ad674c

Commit: 358d88d02f0176217281e80744807b89e2ad674c

Tree: d8e1f80cb881b6722b17be0796424ab46d16741d

Author: Om Chillure

Committer: GitHub

## Message

```
Fix git worktree popup popup no worktree when opened in a project (#55053)

## 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>
```

## Parents

- [00a677e6cf3e1b045f2dd7db67f9e7b37ec7c7b0](https://git.cafe/gitcafe/zed/commit/00a677e6cf3e1b045f2dd7db67f9e7b37ec7c7b0?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zed/tree/358d88d02f0176217281e80744807b89e2ad674c?format=markdown)
