-
-
Notifications
You must be signed in to change notification settings - Fork 100
feat(move): implement move --reparent like amend --reparent #1631
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
base: master
Are you sure you want to change the base?
Conversation
... into dedicated function, to be reused in the future.
claytonrcarter
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for this. The code looks simple enough, and solid. And the test seems thorough enough for the questions that I came in with.
Currently --reparent conflicts with --fixup since I am not yet sure how it should be implemented
I suspect that it would be fine to make --reparent and --fixup conflict, since it's not at all clear to me what the intended result should be. (ie if you are reparenting the source commit, then you're replacing the destination commit with the source ... I think?; or would you be doing the fixup and then reparenting the original child commits of the target onto the newly squashed commit. (effectively reverting the squashed changes))
would like to test this more in real life and see if it's actually working
The tests seem to confirm the behavior, so I think this would be OK to merge (pending the review comments), but it would also be interesting to see how it works for you in real life.
| parent_oids: Vec<NonZeroOid>, | ||
| repo: &Repo, | ||
| ) -> eyre::Result<()> { | ||
| assert!(!parent_oids.is_empty()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's not use an assert!() here, instead returning an Err if parent_oids.is_empty().
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is copied from .move_subtree, my bad. I have changed both occurrences to eyre:bail!.
git-branchless/tests/test_move.rs
Outdated
| // the reparented test3 contains everything, including test1 and test2 | ||
| git.branchless("prev", &[])?; | ||
| { | ||
| let (stdout, _stderr) = git.run(&["show"])?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[suggestion (maybe change)] Maybe consider using git.run(&["show", "--pretty=format:", "--stat", "HEAD"])?; (as is done in test_split). That makes the output much less verbose and may be easier to maintain.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes this looks much better! Implemented.
|
Thank you so much for taking a look! I agree with all the review comment and will try to address them in the coming week (because of day job 😢 About the comments from the original issue #1537 (comment): yes indeed
In the (not so practical) Note that the final git-branchless/git-branchless/tests/test_move.rs Lines 6409 to 6441 in 515faad
where |
Move the `reparent` option from being specific to the `amend` command to a general option within `MoveOptions`. This allows its use across various move-related commands like `restack`, `split`, and `sync`.
Implement the new `reparent` option for the `move` command. This ensures moved subtrees are reparented to their new destination. The `fixup` option now conflicts with `reparent`.
This causes abandoned commits to be reparented to their new destination, mimicking the behavior of `amend --reparent`.
When splitting a commit with `--discard` or `--detach`, the `--reparent` option ensures that the changes from the discarded or detached portion are squashed to the child commit, just like `amend --reparent`. Reparenting is not applied to `InsertAfter` or `InsertBefore` modes as it would simply be a no-op in these cases (the descendants are not changed in the first place).
Allows `sync` to reparent commits onto the main branch, effectively "undoing" intermediate main branch commits that would otherwise be between the original parent and the new parent.
|
I have implemented the consistent behavior for |
Closes #1537. This is done in the following commits:
amend --reparentlogic into a.reparent_subtreemethod for theRebasePlanBuildermoveand possiblyrestack,splitetcin the future (currently not implemented and would be a no-op)(now implemented, see below)movecommand with a fewbuilder.reparent_subtreecalls. Currently--reparentconflicts with--fixupsinceI am not yet sure how it should be implemented (help wanted)the behavior for--fixup --parentmay be ambiguous or confusing for usersmove --reparentand showcase its intended behavior.restack --reparentsplit --reparent(for --stack or --detach)sync --reparentI would like to test this more in real life and see if it's actually working, but I think it would be good to post it here early to gather some feedback: is this feature desired? Would this be the correct way to implement it? I have very limited knowledge on the codebase so all feedbacks are much welcomed. Thank you!