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

Re: How to implement the "amend!" commit ?

From
Taylor Blau <me@ttaylorr.com>
Date
Jan 13, 2021, 18:24 UTC
Message-ID
<X/864HdPtf1km0xZ@nand.local>
In-Reply-To
<CAPSFM5f+cm87N5TO3V+rJvWyrcazybNb_Zu_bJZ+sBH4N4iyow@mail.gmail.com>
Hi Chavri,
On Wed, Jan 13, 2021 at 06:45:25AM +0530, Charvi Mendiratta wrote:
Show 8 quoted lines
> Hi Everyone,
>
> Implementing "amend!" commit would be an alternative to the
> fixup!/squash! commit that addresses the issue as opened here[1]. Also
> the related patches[2], adds the options to `fixup` command in
> interactive rebase and supports the "amend!" commit upon
> `--autosquash`. Next, after discussing with Phillip and Christian,
> there could be 3 possibilities to implement the "amend!" commit (UI):
To make sure that I'm understanding correctly:
  - Your series in [2] teaches the rebase directive 'fixup' two new
    options: -C, and -c. Unlike of the option-less 'fixup' command,
    these new options use the message from the fixup commit instead of
    the original.
    If I'm understanding correctly, this old-style sequence:
        pick aaaaaaaaaa original
        fixup bbbbbbbbbb fixup! new
        exec git commit --amend -C bbbbbbbbbb --no-edit
    should be equivalent to this one:
        pick aaaaaaaaaa original
        fixup -C bbbbbbbbbb fixup! new
  - Separate from that, you are asking about how to implement an
    "amend!" commit which would behave exactly as the 'fixup -C' variant
    that you are proposing.

We should clarify what you mean by "implement". I take it from the remainder of your message that you are really asking about how we should _expose_ this new 'fixup -C' command to users.

Show 14 quoted lines
> Firstly, the `--fixup=<commit>` to have option like,
> `--fixup=reword/amend:<commit>`
>
> So, `git commit --fixup` can have 3 options:
>
> a) `--fixup=<commit>`, work as of now, make fixup! commit.
> b) `--fixup=amend:<commit>`, make "amend!" commit, takes changes and
> also opens the editor for a new message (Here it adds a new message to
> amend! commit's message body and upon autosquash it will fixup up the
> content and reword the original commit message i.e replaces the
> original commit message with the "amend!" commit's message).
> c) `--fixup=reword:<commit>`, makes (empty) "amend!" commit, do not
> take changes and open the editor for a new message(Here, upon
> autosquash it will just reword the original commit message).

I think that this trio is a good path forward, but... `--fixup` behaving as it always has, which is good. Then it makes `--fixup=amend:<commit>` insert a 'fixup -C', and `--fixup=reword:<...>` insert a 'fixup -c'.

> Secondly,
> As an alternative to above, we can use `--fixup=<commit> --amend` and
> `--fixup=<commit> --reword`.
...I think that this option is even better.

Here '--fixup=<commit>' with '--amend' inserts a 'fixup -C' sequencer comamnd, and using the same instead with '--reword' inserts a 'fixup -c' sequencer command.

This is clear to me because '--fixup' makes a commit that is interpreted separately by the sequencer machinery, so any options that are given with it seem to indicate that they will alter how the sequencer interprets the resulting commit, which makes sense.

Of course, it's all somewhat confusing because you have to keep track of which are options to 'git commit', and which are sequencer commands, but I like the direction that you're going in here.

> Next,
> To use only, `--fixup=<commit> --edit` to make the "amend!" commit.
I don't think that this is as good a direction forward.
Show 12 quoted lines
> Also as discussed earlier[3] we are avoiding the use of additional
> options like `git commit --amend=<commit>` inorder to avoid confusion
> of doing similar things in different ways. So, I wonder which could be
> the best way to proceed with or if any other way to implement "amend!"
> commit ?
>
> Thanks and Regards,
> Charvi
>
> [1] https://github.com/gitgitgadget/git/issues/259
> [2] https://lore.kernel.org/git/20210108092345.2178-1-charvi077@gmail.com/
> [3] https://lore.kernel.org/git/95cc6fb2-d1bc-11de-febe-c2b5c78a6850@gmail.com/

Thanks, Taylor

Previous: Charvi MendirattaNext: Taylor Blau
Message 2 of 15 in “How to implement the "amend!" commit ?”
  1. Charvi MendirattaJan 13, 2021
  2. Taylor BlauJan 13, 2021
  3. Taylor BlauJan 13, 2021
  4. Charvi MendirattaJan 14, 2021
  5. Phillip WoodJan 14, 2021
  6. Taylor BlauJan 14, 2021
  7. Phillip WoodJan 15, 2021
  8. Martin ÅgrenJan 15, 2021
  9. Junio C HamanoJan 14, 2021
  10. Phillip WoodJan 15, 2021
  11. Junio C HamanoJan 15, 2021
  12. Charvi MendirattaJan 17, 2021
  13. Junio C HamanoJan 17, 2021
  14. Charvi MendirattaJan 17, 2021
  15. Charvi MendirattaJan 15, 2021

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.