Skip to content

fix: shell out for git remotes when go-git can't read the repo#9410

Open
Di7design wants to merge 1 commit into
mainfrom
dimu/gitutil-worktree-fallback
Open

fix: shell out for git remotes when go-git can't read the repo#9410
Di7design wants to merge 1 commit into
mainfrom
dimu/gitutil-worktree-fallback

Conversation

@Di7design
Copy link
Copy Markdown

gitutil.ExtractRemotes fails in two cases that come up when running the CLI from a git worktree:

  • The repo has extensions.worktreeConfig = true (set automatically when any worktree gets a per-worktree config). go-git rejects this extension, so PlainOpenWithOptions errors out.
  • Inside a git worktree, .git points to the worktree's gitdir but remote config lives in the common gitdir's config. go-git opens the worktree's gitdir and silently reports zero remotes.

rill devtool start is gated on this check and fails to start in both cases.

  • Fall back to git remote -v (via shell) when go-git can't open the repo or returns no remotes.
  • git is already a hard dependency for gitutil.CloneRepo, so this adds no new prerequisite.

Checklist:

  • Covered by tests
  • Ran it and it works as intended
  • Reviewed the diff before requesting a review
  • Checked for unhandled edge cases
  • Linked the issues it closes
  • Checked if the docs need to be updated. If so, create a separate Linear DOCS issue
  • Intend to cherry-pick into the release branch
  • I'm proud of this work!

Developed in collaboration with Claude Code

`gitutil.ExtractRemotes` fails for two cases that arise when running
the CLI from a git worktree:

1. The repo has `extensions.worktreeConfig = true` (set automatically
   when any worktree gets a per-worktree config). go-git rejects this
   extension and `PlainOpenWithOptions` returns an error.
2. Inside a git worktree, `.git` points to the worktree's gitdir, but
   remote config lives in the common gitdir's config. go-git opens the
   worktree's gitdir and silently reports zero remotes.

`rill devtool start` is gated on a remote check and breaks in both
cases. Fall back to `git remote -v` (via shell) when go-git can't open
the repo or returns no remotes. `git` is already a hard dependency for
`gitutil.CloneRepo`, so this adds no new prerequisite.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@Di7design Di7design requested a review from a team as a code owner May 7, 2026 04:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant