Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(branch onto): rebase loop on conflicts #582

Merged
merged 2 commits into from
Feb 21, 2025

Conversation

abhinav
Copy link
Owner

@abhinav abhinav commented Feb 20, 2025

Fixes an issue reported by a user where the following steps cause
a rebase conflict loop:

  • branches A and B share a base, or the base for A is downstack from B
  • branch A is moved on top of B, and the operation runs into a conflict
  • the user resolves the conflict and runs gs rebase continue
  • they are asked to resolve more conflicts, as if replaying all commits

The cause of this issue is this:
when the operation to move A onto B runs into a conflict,
git-spice's internal state is not updated to reflect the new base
(this is correct and desirable).

However, when the operation is re-run after resolving the conflict,
it attempts to replay commits Base..A onto B,
except Base..B overlaps with that range with the new state of the repository.
This forces the user to resolve a bunch of conflicts from replaying those operations,
but the rebase --continue does not ever succeed, and the state is never updated.
so it keeps retrying the same commits on top of B over and over again.

The fix for this is fairly straightforward:
if B is in the Base..A commit range, rebase only B..A instead of Base..A.

@abhinav
Copy link
Owner Author

abhinav commented Feb 20, 2025

This change is part of the following stack:

Change managed by git-spice.

@abhinav abhinav force-pushed the rebase-onto-rebase-loop-repro branch from 9919486 to 66ef79f Compare February 21, 2025 23:01
@abhinav abhinav changed the title [wip] fix: branch onto: rebase loop on conflicts fix: branch onto: rebase loop on conflicts Feb 21, 2025
@abhinav abhinav marked this pull request as ready for review February 21, 2025 23:07
@abhinav abhinav changed the title fix: branch onto: rebase loop on conflicts [fix] branch onto: rebase loop on conflicts Feb 21, 2025
@abhinav abhinav changed the title [fix] branch onto: rebase loop on conflicts fix(branch onto): rebase loop on conflicts Feb 21, 2025
@abhinav abhinav force-pushed the rebase-onto-rebase-loop-repro branch from 66ef79f to 586632a Compare February 21, 2025 23:11
@abhinav abhinav force-pushed the rebase-onto-rebase-loop-repro branch from 586632a to 1ad26ae Compare February 21, 2025 23:18
Unclear why the author/committer is not propagating
but not worth debugging right now.
@abhinav abhinav enabled auto-merge (squash) February 21, 2025 23:27
@abhinav abhinav merged commit ca1ea0b into main Feb 21, 2025
12 checks passed
@abhinav abhinav deleted the rebase-onto-rebase-loop-repro branch February 21, 2025 23:29
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