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

Re: Bug in rebase --autosquash

From
Junio C Hamano <gitster@pobox.com>
Date
Aug 19, 2022, 16:53 UTC
Message-ID
<xmqqpmgwmaxx.fsf@gitster.g>
In-Reply-To
<8p78q4p9-9ro4-p5s4-r738-7sno17rqr414@tzk.qr>
Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:
Show 6 quoted lines
> This demonstrates a somewhat obscure feature where the `fixup!` of a
> `fixup!` magically targets the original commit.
>
> I understand that it is somewhat unintuitive that `fixup! fixup! abc` does
> not target `fixup! abc` but instead `abc`, but that's how the tool has
> been behaving forever.

It certainly is handy when the original commit A has a fixup commit B, which gets later fixed up by another commit C, resulting in a sequence like this:

    $ git rebase -i A~1 C
    pick A original commit
    fixup B fixup! original commit
    fixup C fixup! fixup! original commit

But if the user for some reason finds it is not quite ready to touch the original commit by squashing in the fixes, it may be reasonable to want to squash the two fixes together, so that it can later be applied to the original commit. And it would be one natural way to request that with

    $ git rebase -i A C

that is, leave the history up to A intact, but everything above tweaked. Without --autosquash, you would get

    pick B fixup! original commit
    pick C fixup! fixup! original commit
and you would manually do
    pick B fixup! original commit
    fixup C fixup! fixup! original commit

to squash B and C together into a single fix-up to be applied later. It does not look all too unreasonable to expect the "--autosquash" feature to do that automatically for you.

Thanks.
    
Previous: Johannes Schindelin
Message 4 of 4 in “Bug in rebase --autosquash”
  1. Uwe Kleine-KönigAug 17, 2022
  2. Felipe ContrerasAug 17, 2022
  3. Johannes SchindelinAug 19, 2022
  4. Junio C HamanoAug 19, 2022

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.