Re: [RFC PATCH] rebase: implement --rewind

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Apr 06, 2023 at 12:45:02PM +0200, Ævar Arnfjörð Bjarmason wrote:
My most common use-case for "nested" is certainly less complex that
Johannes's, and is the following:

* I've got e.g. a 10 patch series

* I start rebasing that on "master", solve conflicts with "1..4", and
  am now on a conflict on 5/10.

* It now becomes obvious to me that the even larger conflict I'm about
  to have on 6/10 would be better handled if I went back to 2/10 or
  whatever, did a change I could do here in 5/10 differently, and then
  proceeded.

I.e. when I'm at 5/10 I'd conceptually like to do another "git rebase -i
HEAD~5" or whatever, use the *already rewritten* commits (otherwise I'd
just abort and restast), re-arrange/rewrite them, and when I'm done
return to 5/10.

yes, this patch addresses this use case - mostly.

i'm generally dealing with an even more benign case, because i'm "rebasing" with --keep-base most of the time (and i have the thing aliased to 'reshape' - maybe something for upstream?).

the case of rewinding from a conflicted state currently needs manual handling. i suppose i should detect the state, re-insert the pick, and reset hard out of it, as if --skip was used. the implicit destructiveness feels wrong, though. maybe require --force?

But here's the important bit: Sometimes I'm just wrong about my re-edit
to 2/10 being the right thing, and it would actually just make things
worse, as I might discover in my "nested" rebase once I'm at 4/5 or
whatever.

So being able to do an "--abort" ot that point to go back to the
"un-nested" 5/10 (*not* "original" 5/10) and proceed from there would be
nice.

yeah, i'm experiencing that sometimes, but not often enough to bother automating it. manual recovery by hand-editing the todo after rewinding again did the trick so far.

From a UX perspective I think just as our $PS1 integration can be made
to show "5/10" it would be ideal if in this case we could show
e.g. "5/10 -> 1/5" or whatever. I.e. I'm in a nested rebase of 1/5,
which started from that 5/10".

hmm, i think you just pointed out johannes' hangup to me. ^^

you both are assuming a limited rewind, where you explicitly specify the affected range, and the todo list editor presents only that. you're deriving the term "nested" from the fact that it's an isolated subset of the rewritten commits.

however, i see these problems with that aproach:
- as mentioned in the OP, i might want to move hunks out of the nested range. i could stash them, but then i'm dealing with two methods of organizing the history, which gets really messy - it gets even trickier if i want to move commits *into* the nested range - i'd have to manually insert a pick, and then deal with the possible conflict after unnesting - who says that the nesting point should be the last chance to change my mind? suppose i stop at 10, get the idea to re-edit 5, but after reaching 15 i notice that re-editing 5 (and thus probably also 10) was a terrible idea, so i want to go back to pre-nest 10

now suppose my approach, where the rebase is rewound right to `onto`, and the whole remaining todo is left in place. the nested base is implicitly determined by the first modified line of the rewound todo, so there is no harm in rewinding the whole rebase (*). and the rebase can just continue past the rewind point without anything special happening. if we want to be able to undo the rewind, we push HEAD and the todo list onto a stack. as phillip said, that's basically just a checkpoint, which happens to be automatically created when we are rewinding. that could be presented at the prompt as "REBASE 5/10 [1]" to signify the number of available checkpoints (and you'd access them with 'git rebase --restore [<id>]', quite similarly to stashes).

of course it gets really "interesting" when you want to go back to a checkpoint, but also want to salvage some of the rewritten commits. then you'll have to manually pick commits from the reflog, etc., but i don't see how one could possibly get around the complexity (we could present a combined todo file where alternative versions of commits are shown in comments, but that's quite some effort for only a slight improvement).

(*) actually, there is:
- firstly, having the entire todo in front of you can be rather annoying when it's more than two dozen commits long and the part you want to edit isn't near the beginning. - secondly, skipping over merges doesn't appear to be a thing, so johannes' use case would be *insanely* slow. but that's "only" an implementation issue.

given these problems, i can see that it would make sense to accept an optional argument that limits the depth of the rewind (without impacting the overall approach).

thanks!



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux