gitext-rs / git-stack

Stacked branch management for Git
Apache License 2.0
505 stars 19 forks source link

Supporting moving fixup commits be last commit in their branch #157

Open vlovich opened 2 years ago

vlovich commented 2 years ago

Version

0.3

Use Case

Would be nice if git-stack could be taught to handle fixup commits for parent features by making them the new tips. For example, if I have

--- a commit 1
--- b commit 2
--- feature A commit 3
--- feature B commit 4
--- e commit 5
--- feature C fixup! commit 2

I would like git stack --rebase --fixup move to produce:

--- a commit 1
--- b commit 2
--- c commit 3
--- feature A fixup! commit 2
--- feature B commit 4
--- feature C commit 5

Currently the behavior appears to be very inconsistent and never what I want. Either the fixups are ignored or they end up in the wrong branch

--- a commit 1
--- b commit 2
--- feature A commit 3
--- d commit 4
--- feature B fixup! commit 2
--- feature C commit 5

Requirements

git stack --rebase --fixup move should move the fixup commits to be the new tips of the changed branches.

Possible Solutions

No response

epage commented 2 years ago

I think you are being affected by the bug that was fixed in 0.4.8. I just realized there are several more fixes in master (unrelated to this), so I'd recommend upgrading to the newly released 0.5.0.

vlovich commented 2 years ago

I just tried & what I got was better but still not quite what I want. Our commit policy is to push a fixup commit before squashing so that we can see what changed in the PR. Thus I need the fixup commit to be moved to be the last commit of the branch containing the commit being fixed up, not beside the commit it's fixing up.

So:

⌽ fa131bc Speedup our CI build by 2x.
⌽ 5ba7434 More cleanup
⌽ c64fc1f Some piece of feature 1
⌽ 0d4f837 Some other piece of feature 1
⌽ vlovich/feature-1 (pushed) Final piece of feature 1.
⌽ 66b4dc6 moAR commits
⌽ 163fb6d more commits
⌽ 6aebbfd do something
⌽ 411b244 fixup! Speedup our CI build by 2x.
⌽ 163fb6d fixup! Some other piece of feature 1
⌽ vlovich/feature-2 fixup! Some piece of feature 1

rebased with a hypothetical --fixup move-tip would be:

⌽ fa131bc Speedup our CI build by 2x.
⌽ 5ba7434 More cleanup
⌽ c64fc1f Some piece of feature 1
⌽ 0d4f837 Some other piece of feature 1
⌽ 1c29876 (pushed) Final piece of feature 1.
⌽ 7b95e47 fixup! Speedup our CI build by 2x.
⌽ df1bf3f fixup! Some other piece of feature 1
⌽ vlovich/feature-1 fixup! Some piece of feature 1
⌽ 66b4dc6 moAR commits
⌽ 163fb6d more commits
⌽ vlovich/feature-2 do something
epage commented 2 years ago

I can see how that would be helpful though with the downside that you delay discovering how cleanly you can move the commit to be right after what it fixes.

When doing this workflow, do you eventually do a "move" or do you only need "move-tip" and squash?

The main issue will be finding a way to expose this clearly. I worry a --fixup move-tip won't be very clear. I wonder if there can be a separate config field for fixup move policy but what to call that and what to call the values still needs answering.

vlovich commented 2 years ago

We just move tip and squash so having a confit option that changes where we move to is fine.