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:
Julian Knutsen
2026-01-12 09:45:09 +00:00
committed by GitHub
parent 0d0d2763a8
commit 7b35398ebc
3 changed files with 105 additions and 0 deletions

View File

@@ -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
}