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

restack: Don't use fork point if base hash is up to date #95

Merged
merged 1 commit into from
May 24, 2024

Conversation

abhinav
Copy link
Owner

@abhinav abhinav commented May 24, 2024

When restacking, we run the equivalent of the following command:

git rebase --onto [base] [upstream] [current]

Where,

  • [base]: name of the base branch we're stacking on top of
  • [upstream]: commit to start rebasing from
  • [current]: branch we're rebasing

Commits that match git rev-list [current] --not [upstream]
are included in the rebase.

We track the hash of the base branch as the user uses git-spice
so that we know the best value of [upstream] to use when restacking.

However, our restacking logic was always overriding that
with the fork point between [base] and [current] if available.
This seems unnecessary and possibly faulty
given that our base branch information is more specific.

In this change, we'll only use the fork point as a fallback
if the recorded base hash is not an ancestor of the current branch.

When restacking, we run the equivalent of the following command:

    git rebase --onto [base] [upstream] [current]

Where,

- [base]: name of the base branch we're stacking on top of
- [upstream]: commit to start rebasing from
- [current]: branch we're rebasing

Commits that match `git rev-list [current] --not [upstream]`
are included in the rebase.

We track the hash of the base branch as the user uses git-spice
so that we know the best value of [upstream] to use when restacking.

However, our restacking logic was always overriding that
with the fork point between [base] and [current] if available.
This seems unnecessary and possibly faulty
given that our base branch information is more specific.

In this change, we'll only use the fork point as a fallback
if the recorded base hash is not an ancestor of the current branch.
@abhinav abhinav merged commit 2fd89a0 into main May 24, 2024
5 checks passed
@abhinav abhinav deleted the restack-no-fork-point branch May 24, 2024 03:28
abhinav added a commit that referenced this pull request May 24, 2024
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