Re: [PATCH] rebase -i: use same commit's message and date with f -C
- From
- Kristoffer Haugsbakk <kristofferhaugsbakk@fastmail.com>
- Date
- Sep 23, 2025, 17:37 UTC
- Message-ID
- <4e74c0c0-11a8-42bc-a229-196402628b7e@app.fastmail.com>
- In-Reply-To
- <92d4d585-09e9-4f1d-a471-1ad6b312fa61@app.fastmail.com>
On Tue, Sep 23, 2025, at 10:55, Mathias Rav wrote:
> In `git rebase -i` with the fixup command, the -C flag controls whether > the commit message is taken from the previous or current commit,
That’s also for `fixup -c`. With `fixup -C` it just also does not open the editor.
Maybe this refers to how `amend!` is changed to `fixup -C`?
Show 7 quoted lines
> but currently the author name, email and date are always taken from the > previous commit. The fixup command is used to squash two commits where > one commit has a good message and the other's message does not matter, > and it is usually also the case that the commit with the good message > is the one that has the good authorship information; the other is a > fixup commit that was presumably made by the user moments ago, whereas > the commit with the good message is the one whose date should be kept.
I think the rule from the manual
If you want to fold two or more commits into one, replace the
command "pick" for the second and subsequent commits with
"squash" or "fixup". If the commits had different authors, the
folded commit will be attributed to the author of the first
commit. ...is simple enough. Adding this exception for `fixup -C` doesn’t make sense to me.
Why not use `git commit --amend --reset-author --no-edit` in that case?[1]
Granted using `fixup -C` is more advanced interactive use than what I get into.
† 1: On author date: I had a commit from the first of June that I got
back to. After rewriting the commit message and adding more things
to it the author date still says first of June. For better or worse
this is apparently the “normal” baseline.Show 22 quoted lines
> Most of the time, a fixup commit is made on top of the commit to be > fixed up, in which case the rebase -i fixup command is used without -C. > The fixup -C case arises when an earlier commit in the branch is split, > leaving part of the commit to be squashed into a later commit, in which > case fixup -C would be expected to keep the date on the later commit, > and discard the author date of the ephemeral newly split commit. > > 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. > > Tweak try_to_commit to allow specifying author in addition to AMEND_MSG, > and pass author from the current commit in do_pick_commit in `f -C`. > > Tweak the help text in `git rebase -i` to reflect the changed behavior. > > Add a test that ensures that the author metadata for the second current > commit is kept, and remove some author metadata checks from other tests > that now fail since the author metadata is different (as intended). > > Signed-off-by: Mathias Rav <m@git.strova.dk> > --- >[snip]
-- Kristoffer