Skip to content

fix(rebase): preserve failures before rebase starts - #2

Open
windsornguyen wants to merge 1 commit into
mainfrom
codex/fail-unstarted-rebase
Open

windsornguyen wants to merge 1 commit into
mainfrom
codex/fail-unstarted-rebase

Conversation

@windsornguyen

@windsornguyen windsornguyen commented Jul 12, 2026 •

Copy link
Copy Markdown
Owner

Reproduction

A rebase can fail before Git creates rebase state, such as when the target branch is missing. tryAutoResolveRebase sees no active rebase and returns success.

Fixes github#35.

Change

Returns the original Git error when no rebase was started.

Proof

  • Real Git test reproduces the missing-branch failure
  • The test returned nil before this change and the Git error after it
  • go vet ./...
  • go test -race -count=1 ./...

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: bdf3b37fae

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread internal/git/git.go
for i := 0; i < 1000; i++ {
if !IsRebaseInProgress() {
return nil
return originalErr

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Treat non-started rebase errors as fatal

When git rebase fails before creating .git/rebase-* (for example an invalid or missing branch/old-base ref), this now returns a non-nil error while IsRebaseInProgress() is false. The stack callers such as cascadeRebase treat any non-nil Rebase/RebaseOnto error as a recoverable conflict, save gh-stack-rebase-state, and tell users to run gh stack rebase --continue, but there is no Git rebase to continue, so the original failure is still not surfaced correctly and the user is left in a bogus recovery state. Please return a distinguishable fatal error here or update callers to branch on whether a rebase actually started.

Useful? React with 👍 / 👎.

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.

gh stack rebase silently succeeds when git rebase --onto fails to start (in branch checked out in another worktree)

1 participant