Skip to content

fix(rebase): return HEAD instead of error when conflict_free_rebase is a no-op#2974

Open
Noethix55555 wants to merge 1 commit into
gitui-org:masterfrom
Noethix55555:fix/gu-sync-rebase-noop
Open

fix(rebase): return HEAD instead of error when conflict_free_rebase is a no-op#2974
Noethix55555 wants to merge 1 commit into
gitui-org:masterfrom
Noethix55555:fix/gu-sync-rebase-noop

Conversation

@Noethix55555

Copy link
Copy Markdown

conflict_free_rebase errors with "no commit rebased" when the target branch is already an ancestor of HEAD (zero steps to replay). This shows up in the pull popup as a rebase failed: error for an operation that actually succeeded.

Root cause: when libgit2 finishes the rebase loop immediately (nothing to replay), last_commit stays None and the function returns Err. Git itself exits 0 in this case.

Fix: fall back to get_head_repo() when the loop produces no commits, returning the current HEAD as the result instead of an error.

A regression test (test_noop_already_uptodate) is added that rebases master onto an ancestor branch and asserts the call succeeds and returns the correct commit id.

When the branch is already up-to-date (zero commits to replay),
libgit2 finishes the rebase immediately and the loop body never
executes, leaving last_commit as None.  The previous code turned
that into Err("no commit rebased"), which surfaced in the pull
popup as a spurious rebase-failed error even though the operation
was successful.

Fix: when the loop produces no steps, fall back to get_head_repo()
so the caller receives the current HEAD commit id instead of an error.

Add a regression test that rebases master onto an ancestor branch
and asserts the call succeeds.
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.

1 participant