Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@

## 🆕 Recent Updates

### v2.1.0 - v2.1.9 - Usage widgets, links, new git insertions / deletions widgets, and reliability fixes
### v2.1.0 - v2.1.10 - Usage widgets, links, new git insertions / deletions widgets, and reliability fixes

- **🧩 New Usage widgets (v2.1.0)** - Added **Session Usage**, **Weekly Usage**, **Block Reset Timer**, and **Context Bar** widgets.
- **📊 More accurate counts (v2.1.0)** - Usage/context widgets now use new statusline JSON metrics when available for more accurate token and context counts.
Expand All @@ -58,6 +58,7 @@
- **⏳ Weekly reset timer split (v2.1.7)** - Added a separate `Weekly Reset Timer` widget.
- **⚙️ Custom config file flag (v2.1.8)** - Added `--config <path>` support so ccstatusline can load/save settings from a custom file location.
- **🔣 Unicode separator hex input upgrade (v2.1.9)** - Powerline separator hex input now supports 4-6 digits (full Unicode code points up to `U+10FFFF`).
- **🌳 Bare repo worktree detection fix (v2.1.10)** - `Git Worktree` now correctly detects linked worktrees created from bare repositories.

### v2.0.26 - v2.0.29 - Performance, git internals, and workflow improvements

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ccstatusline",
"version": "2.1.9",
"version": "2.1.10",
"description": "A customizable status line formatter for Claude Code CLI",
"module": "src/ccstatusline.ts",
"type": "module",
Expand Down
21 changes: 13 additions & 8 deletions src/widgets/GitWorktree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,25 +52,30 @@ export class GitWorktreeWidget implements Widget {

private getGitWorktree(context: RenderContext): string | null {
const worktreeDir = runGit('rev-parse --git-dir', context);
if (!worktreeDir) {
if (!worktreeDir)
return null;
}

const normalizedGitDir = worktreeDir.replace(/\\/g, '/');

// /some/path/.git or .git
// /some/path/.git or .git (main worktree of regular repo)
if (normalizedGitDir.endsWith('/.git') || normalizedGitDir === '.git')
return 'main';

// /some/path/.git/worktrees/some-worktree or /some/path/.git/worktrees/some-dir/some-worktree
const marker = '.git/worktrees/';
const markerIndex = normalizedGitDir.lastIndexOf(marker);
if (markerIndex === -1) {
return null;
const repoMarker = '.git/worktrees/';
const repoMarkerIndex = normalizedGitDir.lastIndexOf(repoMarker);
if (repoMarkerIndex !== -1) {
const worktree = normalizedGitDir.slice(repoMarkerIndex + repoMarker.length);
return worktree.length > 0 ? worktree : null;
}

const worktree = normalizedGitDir.slice(markerIndex + marker.length);
// /some/path/worktrees/some-worktree or /some/path/worktrees/some-dir/some-worktree
const bareMarker = '/worktrees/';
const bareMarkerIndex = normalizedGitDir.lastIndexOf(bareMarker);
if (bareMarkerIndex === -1)
return null;

const worktree = normalizedGitDir.slice(bareMarkerIndex + bareMarker.length);
return worktree.length > 0 ? worktree : null;
}

Expand Down
21 changes: 21 additions & 0 deletions src/widgets/__tests__/GitWorktree.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,4 +118,25 @@ describe('GitWorktreeWidget', () => {

expect(render()).toBe('𖠰 no git');
});

it('should render with bare repo worktree', () => {
mockExecSync.mockReturnValueOnce('true\n');
mockExecSync.mockReturnValueOnce('/some/path/worktrees/some-worktree');

expect(render()).toBe('𖠰 some-worktree');
});

it('should render with nested bare repo worktree', () => {
mockExecSync.mockReturnValueOnce('true\n');
mockExecSync.mockReturnValueOnce('/some/path/worktrees/some-dir/some-worktree');

expect(render()).toBe('𖠰 some-dir/some-worktree');
});

it('should handle windows bare repo git-dir paths', () => {
mockExecSync.mockReturnValueOnce('true\n');
mockExecSync.mockReturnValueOnce('C:\\repo\\worktrees\\some-worktree');

expect(render()).toBe('𖠰 some-worktree');
});
});
Loading