Skip to content

fix: support bare repo worktrees in GitWorktree widget#138

Merged
sirmalloc merged 4 commits into
sirmalloc:mainfrom
gn0rt0n:fix/bare-repo-worktree-detection
Mar 4, 2026
Merged

fix: support bare repo worktrees in GitWorktree widget#138
sirmalloc merged 4 commits into
sirmalloc:mainfrom
gn0rt0n:fix/bare-repo-worktree-detection

Conversation

@gn0rt0n

@gn0rt0n gn0rt0n commented Jan 14, 2026

Copy link
Copy Markdown
Contributor

Summary

The GitWorktree widget now correctly detects worktrees from bare repositories.

Previously, it only checked for .git/worktrees/ in the path, but bare repos store worktree metadata at <bare-repo>/worktrees/<name> without the .git prefix.

Before: Worktrees from bare repos showed "no git" instead of the worktree name
After: Correctly displays the worktree name

Changes

  • Added check for /worktrees/ pattern when .git/worktrees/ isn't found
  • Added tests for bare repo worktree detection

Test plan

  • All existing tests pass
  • New tests added for bare repo worktrees
  • Manually verified with a bare repo worktree setup

Example

Bare repo setup:

/path/to/repo/           <- bare repo (objects/, refs/, HEAD directly here)
├── worktrees/feature-x/ <- worktree metadata
└── trees/feature-x/     <- actual working directory

Running git rev-parse --git-dir from trees/feature-x/ returns /path/to/repo/worktrees/feature-x, which now correctly extracts feature-x as the worktree name.

gn0rt0n and others added 4 commits January 14, 2026 15:29
The GitWorktree widget now correctly detects worktrees from bare
repositories. Previously, it only checked for `.git/worktrees/` in
the path, but bare repos store worktree metadata at
`<bare-repo>/worktrees/<name>` without the `.git` prefix.

This adds an additional check for `/worktrees/` pattern when the
`.git/worktrees/` pattern isn't found.

Fixes detection for setups like:
- Bare repo at: /path/to/repo (contains objects/, refs/, HEAD, etc.)
- Worktree at: /path/to/repo/trees/feature-x
- Git dir: /path/to/repo/worktrees/feature-x
@sirmalloc sirmalloc merged commit 990f270 into sirmalloc:main Mar 4, 2026
@sirmalloc

Copy link
Copy Markdown
Owner

Thanks for this, it'll be published as v2.1.10 shortly

BenIsLegit pushed a commit to BenIsLegit/ccstatusline-usage that referenced this pull request Mar 28, 2026
* fix: support bare repo worktrees in GitWorktree widget

The GitWorktree widget now correctly detects worktrees from bare
repositories. Previously, it only checked for `.git/worktrees/` in
the path, but bare repos store worktree metadata at
`<bare-repo>/worktrees/<name>` without the `.git` prefix.

This adds an additional check for `/worktrees/` pattern when the
`.git/worktrees/` pattern isn't found.

Fixes detection for setups like:
- Bare repo at: /path/to/repo (contains objects/, refs/, HEAD, etc.)
- Worktree at: /path/to/repo/trees/feature-x
- Git dir: /path/to/repo/worktrees/feature-x

* chore: remove accidental npm lockfile from PR branch

* chore: bump version to 2.1.10 and update recent updates

---------

Co-authored-by: Matthew Breedlove <sirmalloc@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants