Skip to content

fix for rev-parse error when rebasing over deleted branches#41

Open
skarim wants to merge 1 commit intoskarim/fix-fast-forwardfrom
skarim/fix-rebase-deleted
Open

fix for rev-parse error when rebasing over deleted branches#41
skarim wants to merge 1 commit intoskarim/fix-fast-forwardfrom
skarim/fix-rebase-deleted

Conversation

@skarim
Copy link
Copy Markdown
Collaborator

@skarim skarim commented Apr 16, 2026

Fix rev-parse error when rebasing over deleted branches

When a merged branch's remote ref was deleted (e.g. "Automatically delete head branches"), gh stack rebase would fail with a rev-parse error because it tried to resolve refs for all branches, including ones that no longer exist.

Fix: Filter out merged branches that don't exist locally before calling RevParseMulti to snapshot original refs. These branches are already skipped during the actual rebase cascade.

Copilot AI review requested due to automatic review settings April 16, 2026 14:58
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses a failure during gh stack rebase when the stack contains merged branches whose local refs no longer exist (e.g., branch auto-deleted after merge), by avoiding git rev-parse on refs that can’t be resolved.

Changes:

  • Skip merged branches that don’t exist locally when building the ref list for RevParseMap, preventing rev-parse errors.
  • Update existing rebase tests to account for the new BranchExists behavior.
  • Add a new regression test covering the “merged + deleted branch” scenario.
Show a summary per file
File Description
cmd/rebase.go Excludes merged non-existent branches from the batch RevParseMap resolution to prevent rev-parse failures.
cmd/rebase_test.go Adjusts mocks for the new branch-existence check and adds a regression test for deleted merged branches.

Copilot's findings

Tip

Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

  • Files reviewed: 2/2 changed files
  • Comments generated: 2

Comment thread cmd/rebase.go
Comment thread cmd/rebase_test.go
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants