Fix: Enable HEAD resolution in git worktrees#741
Conversation
Enable EnableDotGitCommonDir in go-git's PlainOpenWithOptions so that ref resolution follows the commondir chain. Without this, HEAD in a linked worktree points to a branch whose ref lives in the main repo's .git/refs, and go-git fails with "reference not found". Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
Claude finished @meekrosoft's task in 1m 27s —— View job PR Review: Fix HEAD resolution in git worktrees
Static AnalysisAll checks pass: ReviewThis is a clean, well-scoped fix. The change is minimal (swapping A few observations: Code change — No concerns. Test quality — Good coverage of the three key operations. The test creates a real git worktree via TODO.md — Follows the repo's slice tracking convention correctly. No issues found. This is a solid single-slice fix — small, focused, well-tested. LGTM. 👍 |
Summary
Enable
EnableDotGitCommonDiroption ingitview.New()to properly resolve HEAD references in git worktrees.Changes
gitView.New()to usegit.PlainOpenWithOptions()withEnableDotGitCommonDir: trueTestNewGitViewFromWorktree()that validates:BranchName()returns correct branch in worktree contextGetCommitInfoFromCommitSHA("HEAD", ...)resolves correctly in worktreeImpact
Users can now use gitview operations from git worktree paths without errors when resolving HEAD references.