From 3db961c4bba29ac33c1351ac6041dffea93daa9f Mon Sep 17 00:00:00 2001 From: gastown/polecats/slit Date: Tue, 30 Dec 2025 22:36:11 -0800 Subject: [PATCH] Fetch remote tracking ref before comparing in BranchPushedToRemote (gt-ztr0k) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit After confirming remote branch exists via ls-remote, fetch to ensure the local origin/branch ref exists before using it in rev-list comparison. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- internal/git/git.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/internal/git/git.go b/internal/git/git.go index 165e8015..77300fea 100644 --- a/internal/git/git.go +++ b/internal/git/git.go @@ -743,7 +743,11 @@ func (g *Git) BranchPushedToRemote(localBranch, remote string) (bool, int, error return n == 0, n, nil } - // Remote branch exists - check if local is ahead + // Remote branch exists - fetch to ensure we have the local tracking ref + // This handles the case where we just pushed and origin/branch doesn't exist locally yet + _, _ = g.run("fetch", remote, localBranch) + + // Check if local is ahead count, err := g.run("rev-list", "--count", remoteBranch+"..HEAD") if err != nil { return false, 0, fmt.Errorf("counting unpushed commits: %w", err)