fix(git): fetch origin after configuring refspec for bare clones (#384)
Bare clones don't have refs/remotes/origin/* populated by default.
The configureRefspec fix (a91e6cd6) set up the fetch config but didn't
actually run a fetch, leaving origin/main unavailable.
This caused polecat worktree creation to fail with:
fatal: invalid reference: origin/main
Fixes:
1. Add git fetch after configureRefspec in bare clone setup
2. Add fetch before polecat worktree creation (ensures latest code)
The second fix matches RepairWorktreeWithOptions which already had a fetch.
Related: #286
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -261,6 +261,12 @@ func (m *Manager) AddWithOptions(name string, opts AddOptions) (*Polecat, error)
|
||||
return nil, fmt.Errorf("finding repo base: %w", err)
|
||||
}
|
||||
|
||||
// Fetch latest from origin to ensure worktree starts from up-to-date code
|
||||
if err := repoGit.Fetch("origin"); err != nil {
|
||||
// Non-fatal - proceed with potentially stale code
|
||||
fmt.Printf("Warning: could not fetch origin: %v\n", err)
|
||||
}
|
||||
|
||||
// Determine the start point for the new worktree
|
||||
// Use origin/<default-branch> to ensure we start from the rig's configured branch
|
||||
defaultBranch := "main"
|
||||
|
||||
Reference in New Issue
Block a user