git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: Is there any way to "interrupt" a rebase?

From
Jeff King <peff@peff.net>
Date
Feb 20, 2018, 20:56 UTC
Message-ID
<20180220205603.GA13721@sigill.intra.peff.net>
In-Reply-To
<nycvar.QRO.7.76.6.1802201240010.31@ZVAVAG-6OXH6DA.rhebcr.pbec.zvpebfbsg.pbz>
On Tue, Feb 20, 2018 at 12:44:51PM +0100, Johannes Schindelin wrote:
Show 16 quoted lines
> > It might be even possible to design a new subcommand for the interactive
> > rebase to facilitate a variation of this strategy (possibly even making
> > use of the fact that the interactive rebase accumulates mappings between
> > the original commits and the rewritten ones in
> > $GIT_DIR/rebase-merge/rewritten-list, intended for use in the post-rewrite
> > hook).
> 
> This feature might look somewhat like this:
> 
> 	git rebase --replay-latest-commits 3
> 
> and it would not even have to look at the `rewritten-list`. All it would
> do is to put back the latest `pick` from the `done` file (in case of merge
> conflicts) into the `git-rebase-todo` file, then insert `pick lines for
> HEAD~3.. at the beginning of that todo file, and then `git reset --hard
> HEAD~3`.
Keep in mind that the "pick" lines could be "edit", "squash", etc.

I think the general form of your original email's proposal is something like: What if we had a "git rebase --rewind" that could "undo" the prior command? So if I had a todo file like:

  pick 1
  edit 2
  x make test
  edit 3
  x make test
  pick 4
and I failed at the second "make test", then I'd have:
  pick 1
  edit 2
  x make test
  edit 3
  x make test

in the "done" file, with the final pick remaining in "todo". Could I then ask to "rewind" my state by moving "x make test" back to the "todo". And two rewinds would get me back to applying patch 3, which I could then fix up and re-run my test. Or four rewinds would get me back to patch 2, which maybe is where I made the initial mistake.

That's a bit more primitive than what you're proposing in this follow-on, because you'd be doing the replay yourself (unless we remap the commits). But it's very easy to reason about and implement.

Anyway, just musing at this point. I haven't thought it through, but I like the direction of everything you're saying. ;)

-Peff
Previous: Johannes SchindelinNext: Jacob Keller
Message 6 of 10 in “Is there any way to "interrupt" a rebase?”
  1. Hilco WijbengaFeb 19, 2018
  2. brian m. carlsonFeb 19, 2018
  3. Hilco WijbengaFeb 19, 2018
  4. Johannes SchindelinFeb 20, 2018
  5. Johannes SchindelinFeb 20, 2018
  6. Jeff KingFeb 20, 2018
  7. Jacob KellerFeb 20, 2018
  8. Phillip WoodFeb 23, 2018
  9. Jeff KingFeb 20, 2018
  10. Phillip WoodFeb 20, 2018

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.