Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@draftcode
Copy link
Contributor

This is a special case that can happen when the user has two branches
that share some history. A scenario is:

  1. A user creates a new branch from main. Add commits. Create a PR.
  2. The user creates another branch off from the first branch, but with
    normal git checkout -b rather than av branch. Add commits. Create
    a PR. This new branch now contains all commits from the first branch.
    However, the parent of this new branch is still main.
  3. The user tries to correct the parent-child relationship by
    reparenting the new branch onto the first branch. i.e. av reparent --parent <first-branch> on the new branch.

When this happens, and when there are multiple commits on the first
branch, Git tries to replay those commits when rebasing the second
branch onto the first branch, which can lead to conflicts.

There can be another way to create this situation, but after all, the
point here is that we don't need to change the Git history when the new
parent is already an ancestor of the current branch, and the new parent
also contains the previous parent as an ancestor. Detect this case in
sequencer and skip the rebase entirely. We still need to update the DB
in order to track the new parent-child relationship, so we do that while
skipping the Git rebase.

…ddle of the branch's history

This is a special case that can happen when the user has two branches
that share some history. A scenario is:

1. A user creates a new branch from `main`. Add commits. Create a PR.
2. The user creates another branch off from the first branch, but with
   normal `git checkout -b` rather than `av branch`. Add commits. Create
   a PR. This new branch now contains all commits from the first branch.
   However, the parent of this new branch is still `main`.
3. The user tries to correct the parent-child relationship by
   reparenting the new branch onto the first branch. i.e. `av reparent
   --parent <first-branch>` on the new branch.

When this happens, and when there are multiple commits on the first
branch, Git tries to replay those commits when rebasing the second
branch onto the first branch, which can lead to conflicts.

There can be another way to create this situation, but after all, the
point here is that we don't need to change the Git history when the new
parent is already an ancestor of the current branch, and the new parent
also contains the previous parent as an ancestor. Detect this case in
sequencer and skip the rebase entirely. We still need to update the DB
in order to track the new parent-child relationship, so we do that while
skipping the Git rebase.
@draftcode draftcode requested a review from a team as a code owner September 22, 2025 09:27
@aviator-app
Copy link
Contributor

aviator-app bot commented Sep 22, 2025

Current Aviator status

Aviator will automatically update this comment as the status of the PR changes.
Comment /aviator refresh to force Aviator to re-examine your PR (or learn about other /aviator commands).

This PR was merged using Aviator.


See the real-time status of this PR on the Aviator webapp.
Use the Aviator Chrome Extension to see the status of your PR within GitHub.

@aviator-app
Copy link
Contributor

aviator-app bot commented Sep 22, 2025

✅ FlexReview Status

Common Owner: aviator-co/engineering (expert-load-balance assignment)
Owner and Assignment:

  • 🔒 aviator-co/engineering (expert-load-balance assignment)
    Owned Files
    • e2e_tests/reparent_test.go
    • internal/git/mergebase.go
    • internal/sequencer/sequencer.go
    CODEOWNERS Required Files
    • e2e_tests/reparent_test.go
    • internal/git/mergebase.go
    • internal/sequencer/sequencer.go

Review SLO: 7 business hours if PR size is <= 200 LOC for the first response.

@aviator-app aviator-app bot requested a review from simsinght September 22, 2025 09:28
@aviator-app aviator-app bot merged commit ac449d3 into master Sep 23, 2025
5 checks passed
@aviator-app aviator-app bot deleted the handle_reparent_in_middle branch September 23, 2025 00:16
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.

3 participants