Skip to content

fix(switch): resolve main worktree path from worktree list#79

Merged
javoire merged 1 commit intomainfrom
fix/switch-main-worktree
Mar 12, 2026
Merged

fix(switch): resolve main worktree path from worktree list#79
javoire merged 1 commit intomainfrom
fix/switch-main-worktree

Conversation

@javoire
Copy link
Owner

@javoire javoire commented Mar 12, 2026

Summary

  • Fix stack switch <base-branch> (e.g. ss main) resolving to the wrong path when run from a worktree
  • GetRepoRoot() uses git rev-parse --show-toplevel which returns the current worktree's root, not the main repo — now uses git worktree list for all branches uniformly

… repo root

GetRepoRoot() uses `git rev-parse --show-toplevel` which returns the
current worktree's root, not the main repo root. This caused `ss main`
to resolve to the wrong path when run from a worktree.

Use `git worktree list` for all branches uniformly, which always returns
the correct path.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@javoire javoire marked this pull request as ready for review March 12, 2026 19:23
@javoire javoire merged commit 9d68dff into main Mar 12, 2026
1 check passed
@javoire javoire deleted the fix/switch-main-worktree branch March 12, 2026 19:23
javoire pushed a commit that referenced this pull request Mar 12, 2026
…026-03-12)

### Bug Fixes

* **switch:** resolve main worktree path from worktree list instead of repo root ([#79](#79)) ([9d68dff](9d68dff))
@javoire
Copy link
Owner Author

javoire commented Mar 12, 2026

🎉 This PR is included in version 1.22.1 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant