Skip to content

fix: support bare repo worktrees in GitWorktree widget#138

Open
gn0rt0n wants to merge 1 commit intosirmalloc:mainfrom
gn0rt0n:fix/bare-repo-worktree-detection
Open

fix: support bare repo worktrees in GitWorktree widget#138
gn0rt0n wants to merge 1 commit intosirmalloc:mainfrom
gn0rt0n:fix/bare-repo-worktree-detection

Conversation

@gn0rt0n
Copy link

@gn0rt0n gn0rt0n commented Jan 14, 2026

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.

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
zoonderkins added a commit to zoonderkins/ccstatusline that referenced this pull request Jan 21, 2026
Merged PRs:
- sirmalloc#138: fix: support bare repo worktrees in GitWorktree widget
- sirmalloc#135: feat: add git-indicators widget
- sirmalloc#132: fix: Windows terminal width detection
- sirmalloc#131: feat: Task Timer widget
- sirmalloc#123: feat: Add backups for settings.json
- sirmalloc#121: feat: Add configurable context warning alerts
- sirmalloc#120: feat: Add Mercurial support
- sirmalloc#119: feat: Add Git Root Dir widget
- sirmalloc#58: feat: Add support for local/project settings

Fixes Issues:
- sirmalloc#117: Windows tput cols creates null file
- sirmalloc#122: claude's settings.json deleted/lost
- sirmalloc#112: Add mercurial support

Additional fixes:
- Resolved circular dependency in renderer.ts/widgets.ts
- Fixed lint errors in multiple files
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

1 participant