-
Notifications
You must be signed in to change notification settings - Fork 68
Description
Description
When running git gtr list from inside a worktree (rather than the main repo), the output is incorrect:
- It only shows the current worktree
- It labels the current worktree as
[main repo] - The actual main repo and other worktrees are missing
This also breaks git gtr go 1, which is supposed to navigate to the main repo worktree. Since the tool misidentifies the current worktree as the main repo, go 1 just stays in the current worktree.
Steps to reproduce
# From the main repo — works correctly:
cd ~/Code/my-repo
git gtr list
# BRANCH PATH
# ------ ----
# main [main repo] /Users/me/Code/my-repo
# testing /Users/me/Code/my-repo-worktrees/testing
# From a worktree — incorrect output:
cd ~/Code/my-repo-worktrees/testing
git gtr list
# BRANCH PATH
# ------ ----
# testing [main repo] /Users/me/Code/my-repo-worktrees/testing
# go 1 also broken from worktree — stays in current worktree instead of navigating to main:
cd ~/Code/my-repo-worktrees/testing
git gtr go 1
# Navigates to /Users/me/Code/my-repo-worktrees/testing instead of /Users/me/Code/my-repoRoot cause
discover_repo_root() in lib/core.sh uses git rev-parse --show-toplevel, which returns the worktree's own root when run from inside a worktree, not the main repository root.
This causes resolve_base_dir() to compute the wrong base_dir (e.g. my-repo-worktrees/testing-worktrees instead of my-repo-worktrees), so no sibling worktrees are found. It also means any command relying on _ctx_repo_root to identify the main repo (like go 1) will incorrectly point to the current worktree.
Environment
- git gtr version 2.3.0
- git version 2.48.1
- macOS (Apple Silicon)