Skip to content

git gtr ai/go fails when branch is checked out in main working tree #127

Description

@echarrod

Description

When a branch is checked out in the main working tree (not a linked worktree), git gtr ai <branch> and git gtr go <branch> fail with "Worktree not found for branch", even though git worktree list correctly shows it.

The root cause is that resolve_target()/resolve_worktree() only searches linked worktrees in the worktrees directory and does not consider the main working tree as a valid match.

This is distinct from #123, which was about discover_repo_root() returning the wrong path when called from inside a linked worktree.

Steps to reproduce

# Main repo has branch checked out
cd ~/Code/my-repo
git checkout my-feature-branch

# git worktree list shows it correctly
git worktree list
# /Users/me/Code/my-repo                abc1234 [my-feature-branch]
# /Users/me/Code/my-repo-worktrees/other def5678 [other-branch]

# But git gtr can't find it
git gtr ai my-feature-branch
# [x] Worktree not found for branch: my-feature-branch

git gtr go my-feature-branch
# [x] Worktree not found for branch: my-feature-branch

Expected behaviour

git gtr should recognise the main working tree when resolving a branch name, falling through to it when no linked worktree matches.

Environment

  • git gtr version 2.3.0 (installed via Homebrew)
  • git version 2.48.1
  • macOS (Apple Silicon)

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions