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:
@@ -194,6 +194,12 @@ func configureRefspec(repoPath string) error {
|
||||
if err := cmd.Run(); err != nil {
|
||||
return fmt.Errorf("configuring refspec: %s", strings.TrimSpace(stderr.String()))
|
||||
}
|
||||
// Fetch to populate refs/remotes/origin/* so worktrees can use origin/main
|
||||
fetchCmd := exec.Command("git", "-C", repoPath, "fetch", "origin")
|
||||
fetchCmd.Stderr = &stderr
|
||||
if err := fetchCmd.Run(); err != nil {
|
||||
return fmt.Errorf("fetching origin: %s", strings.TrimSpace(stderr.String()))
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user