-
-
Notifications
You must be signed in to change notification settings - Fork 89
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
feat(move): Add --fixup
to squash moved commits into the destination
#545
Conversation
735d4b8
to
dda62dc
Compare
I just pushed a new stack that has in-mem and on-disk rebases working for (almost) all tests. The last test (in a separate commit) is still buh-roken and I'm just parking it for now so I can ruminate on it some more. I think it's just coming down to the order in which the rebase commands are executed, thus the order in which they're added to the queue. (That is what fixed my problem w/ on-disk rebases: they just weren't being executed in the correct order.) |
Sorry for the ongoing monologue, but I'm making progress: all on-disk tests are passing, and I'm close to all in-mem tests, too. The last test revealed a misconception regarding my usage and implementation of |
c2de030
to
16bfc55
Compare
And, we're good! All tests passing and the amend is working correctly (I think). I still have some proofreading and clean up to do, but I think it's at least working. I'll be playing with it for a few days to see how it behaves under real use. |
Sorry I wasn't much help with this! Hopefully I'll have some time to review this weekend or next week. |
32dbd59
to
b163b8b
Compare
Just to check, this flag doesn't replace the original commits, right? Would be cool to combine with #553 so that you could replace the original commits. Then a proper squash would be git move --exact "<revset>" --replace "<revset>" --fixup |
b163b8b
to
58e7d29
Compare
I just looked through the tests—this is so cool! 😍 |
283a368
to
ce7a921
Compare
ce7a921
to
e466d38
Compare
Update: this has been dealt with.
|
03e6a84
to
0212e9a
Compare
b469a06
to
30c18e0
Compare
OK, now I think this is really working. My previous version was naively replacing trees w/o actually comparing their contents, but this version is actually doing what one would expect it to be doing, at least according to the tests. The implementation is still pretty rough and gross and I'll need to go back and deal with FIXMEs, fill in error messages, wrap some |
30c18e0
to
1ce18fe
Compare
I'll leave this closed until I get further with it, but the branch is rebased and up to date at https://github.com/claytonrcarter/git-branchless/tree/move-fixup |
Reopening this PR. This seems to be working as expected for nearly all day-to-day uses, and the code is as good as I can get w/o having add'l 👀 on it. |
282023b
to
8f5ebec
Compare
I'm assuming that the CI lint error is unrelated. I don't get any clippy warnings locally w/ Rust 1.70, but it looks like CI is using 1.71. Also the error is at |
Yup. Fixed in #996 |
Fwiw I've seen this behaviour with regular rebases as well. I don't think it always happens for me tho |
8f5ebec
to
45299a9
Compare
45299a9
to
001e094
Compare
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.
Thanks for implementing!
0268458
to
1b93c7a
Compare
Parking this for the night. There are a couple more things to work through, but most feedback has been resolved. I want to give this another full read through, too, just to be fussy. |
15c9aa6
to
50614d8
Compare
da29097
to
0559a70
Compare
Existing test functions are aimed more at checking the existence of files, not necessarily the contents of them.
Existing `AmendFastOptions` only support amending from the working copy or index, but we can't use either of these for implementing something like squashing fixup commits because we need to use the entries from an existing commit.
This is just the basic data structure support for holding multiple commits. The actual implementation of applying multiple commits will come next.
This only implements in-memory rebases/fixups. On-disk rebases can come later.
0559a70
to
3ad2f74
Compare
🎉 Thanks for your patience and help on this @arxanas. If you notice anything wonky, let me know and I can look into it. |
BTW I looked into this further and I was able to repro this on (pre-merge) master, so I don't think it's related to this PR. Thanks again @pokey |
Summary
As the title says, this adds a
move --fixup
flag to squash commits into the destination, in memory or on disk. With this, both of these use cases:rebase -i
+ reordering & marking asfixup!
reword --fixup <dest> <revset> ; rebase -i --autosquash
Can be replaced with just
move -d <dest> -x <revset> --fixup
Add'l examples:
commit
instead ofamend
, lets squash HEAD into it's parent:move -d @~ -x @ --fixup
move -d head(stack()) -s children(head(stack())) --fixup
The original idea came from #538 (review) and it's taken me most of a year of on and (mostly) off work to get it working.
Status
# This is a combination of ...
commits leftover.add --updated ; absorb ; rebase -i --autosquash
, it seems to work fine w/o leftover commits.--fixup -m
to kick things out to disk; and thus probably the rebase plan that I'm creating for on disk rebases or some of the changes related to that.hide 'stack() - main..branches()'
Review request
13 files changed, 2479 insertions(+), 204 deletions(-)
), but most of these (1929 insertions) are new tests.git
commands fed torebase -i
. This involved lots of manual commit rewriting and hiding to get the order and final tree right. This works (mostly, see above) but feels really clunky and heavy handed.FIXME
comments that I left in place w/ questions and/or concerns about my implementation.--fixup
) and API (structs and such).As always, I welcome any feedback, guidance or suggestions. This has been tricky to get my head around, but I've found it very satisfying to use. I'm pretty happy w/ how it works, and I'd love to get it polished up and merged. Thank you!
Original description
@arxanas I could use some help with this.This seems to be working for simple cases (ie in memory sticks) but I think I could use some guidance to get unblocked on where to go next. Specifically, I'm having a hard time getting my head around how to handle on-disk fixup rebases and having some issues with fixing up complicated commit graphs. I feel like I'm playing whack-a-mole with errors and conditions: if I get one test working, another breaks; when I get that working, the other one breaks; etc, and I'm left wondering if my approach is heading in the wrong direction and/or is too rigid or something.
This is still pretty "draft"; please don't be too alarmed by the ugly bits that I need to go back through and clean up! 😄
I added some code that uses
git2::Tree::iter()
directlyI started to work on this, but it felt very copy-pasty and boilerplate-y and seemed to add a lot more code than I was expecting compared to just using
tree.inner.iter()
, plus other parts ofrepo.rs
already usetree.inner.iter()
, so I gave up and moved on to more fun stuff. 😆 Does it seem OK to leave that as is, or would you prefer that it be wrapped?In-memory fix ups seem to work for stick stacks, but fixup rebases that involve trees are being left in a "needs restack" state.
Is this inevitable, or is there is a convenient way to recognize and automatically restack in cases like these? (See
test_move_fixup_complicated
.On disk rebase is not workingUpdate On disk fixup rebases are working.SkipUpstreamAppliedCommit
after everyFixUp
. This helps in some cases, but not all, and it makes in-memory fixups involving multiple fixup commits complicated b/c it's hard to keep track of the target/fixed-up commit as it's always being "rewritten to zero".RebaseCommands
differently, so thatSkipUpstreamAppliedCommit
is only called at the end of the rebase?post-rewrite
etc hooks the info they need to figure things out?