Re: [PATCH] rebase -i: use same commit's message and date with f -C
- From
Mathias Rav <m@git.strova.dk>
- Date
- Sep 24, 2025, 15:21 UTC
- Message-ID
- <7de3da11-6191-4fa3-bd0d-842dc45690e7@app.fastmail.com>
- In-Reply-To
- <0a14a93e-7da2-43e1-9d71-c58a69c7a4af@kdbg.org>
On Wed, Sep 24, 2025, at 10:47 AM, Johannes Sixt wrote:
Show 26 quoted lines
> Am 23.09.25 um 23:38 schrieb Junio C Hamano: >> "Mathias Rav" <m@git.strova.dk> writes: >>> Change the behavior so that fixup with -C takes both message and author >>> from the current commit, instead of taking the author from the previous. >> >> I am somewhat negative to this change. I am perfectly fine to have >> a separate "I may have started from that previous one, but that was >> so broken that I essentially dismantled the original and replaced >> with the new one. It is better to attribute the credit to whoever >> did this last one that is replacing" command. But the "fixup" >> command people have been familiar with would be different, I would >> think. > > The common situation where the proposed change is handy isn't where a > previous commit is fixed up. > > Sometimes, a previous commit is a fixup for a later one, for example, a > change slipped into in earlier commit that should go into a later commit > and has been split off into its own commit. Many times it would be > sufficient to reorder the commits and be done. However, sometimes (and > not even infrequently), reordering the commits introduces conflicts that > do not happen if the order remains. Here, we want the proposed feature. > > Since your argument hinges on the word and meaning of "fixup" (which I > can buy somewhat), we could extend "squash" with an option that > specifies which commit supplies the date and authorship metadata.
I have never used the "amend!" autosquash feature and I was not aware of it until I stepped through the code in sequencer.c to implement my proposed change. I think the `git commit --amend` manual explains quite nicely why you could want to keep the author of one commit and the message of another.
Before discovering "f -C" to achieve the "fixdown" behavior, as Hannes describes, I used "x f" to invoke my own single-letter shell script to achieve the behavior I wanted, and I guess I am fine with going back to that for the cases where I want to preserve author dates (which, to be fair, is often not that important to me).
For completeness, the implementation is ~/.local/lib/git-rebase-utils/f
#!/bin/sh git cherry-pick -n "$1" && git commit --amend -nC "$1"
...with shell alias git='PATH=~/.local/lib/git-rebase-utils:$PATH \git' allowing "x f" in git rebase -i without polluting the regular $PATH.