fix(rebase): return HEAD instead of error when conflict_free_rebase is a no-op#2974
Open
Noethix55555 wants to merge 1 commit into
Open
fix(rebase): return HEAD instead of error when conflict_free_rebase is a no-op#2974Noethix55555 wants to merge 1 commit into
Noethix55555 wants to merge 1 commit into
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
conflict_free_rebaseerrors 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 arebase failed:error for an operation that actually succeeded.Root cause: when libgit2 finishes the rebase loop immediately (nothing to replay),
last_commitstaysNoneand the function returnsErr. 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.