* [PATCH] rebase -i: use same commit's message and date with f -C
@ 2025-09-23 8:55 Mathias Rav
2025-09-23 9:21 ` Karthik Nayak
` (5 more replies)
0 siblings, 6 replies; 14+ messages in thread
From: Mathias Rav @ 2025-09-23 8:55 UTC (permalink / raw)
To: git; +Cc: Junio C Hamano, Phillip Wood
In `git rebase -i` with the fixup command, the -C flag controls whether
the commit message is taken from the previous or current commit,
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.
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>
---
I described my own workflow for fixup -C above,
and it's the only use of fixup -C I'm aware of.
If the current behavior of keeping message from one
and author from another is useful in someone else's
workflow, then I'm happy to be enlightened.
Correct author dates are certainly more nice-to-have
than need-to-have in most git workflows, but I think
it's worthwhile to have git go the extra mile here.
rebase-interactive.c | 4 ++--
sequencer.c | 5 +++--
t/t3437-rebase-fixup-options.sh | 15 ++++++++++-----
3 files changed, 15 insertions(+), 9 deletions(-)
diff --git a/rebase-interactive.c b/rebase-interactive.c
index 809f76a87b..dd303168c2 100644
--- a/rebase-interactive.c
+++ b/rebase-interactive.c
@@ -53,8 +53,8 @@ void append_todo_help(int command_count,
"s, squash <commit> = use commit, but meld into previous commit\n"
"f, fixup [-C | -c] <commit> = like \"squash\" but keep only the previous\n"
" commit's log message, unless -C is used, in which case\n"
-" keep only this commit's message; -c is same as -C but\n"
-" opens the editor\n"
+" keep this commit's message and date; -c is same as -C\n"
+" but opens the editor\n"
"x, exec <command> = run command (the rest of the line) using shell\n"
"b, break = stop here (continue rebase later with 'git rebase --continue')\n"
"d, drop <commit> = remove commit\n"
diff --git a/sequencer.c b/sequencer.c
index aaf2e4df64..80209b6b07 100644
--- a/sequencer.c
+++ b/sequencer.c
@@ -1560,7 +1560,8 @@ static int try_to_commit(struct repository *r,
strbuf_addstr(msg, orig_message);
hook_commit = "HEAD";
}
- author = amend_author = get_author(message);
+ if (!author)
+ author = amend_author = get_author(message);
repo_unuse_commit_buffer(r, current_head,
message);
if (!author) {
@@ -2419,7 +2420,7 @@ static int do_pick_commit(struct repository *r,
strbuf_addstr(&ctx->message, oid_to_hex(&commit->object.oid));
strbuf_addstr(&ctx->message, ")\n");
}
- if (!is_fixup(command))
+ if (is_fixup_flag(command, item->flags) || !is_fixup(command))
author = get_author(msg.message);
}
ctx->have_message = 1;
diff --git a/t/t3437-rebase-fixup-options.sh b/t/t3437-rebase-fixup-options.sh
index 5d306a4769..2361d3fb78 100755
--- a/t/t3437-rebase-fixup-options.sh
+++ b/t/t3437-rebase-fixup-options.sh
@@ -85,6 +85,15 @@ test_expect_success 'simple fixup -C works' '
test_commit_message HEAD -m "A2"
'
+test_expect_success 'fixup -C keeps second commit date' '
+ test_when_finished "test_might_fail git rebase --abort" &&
+ git checkout --detach A2 &&
+ get_author HEAD >expect &&
+ FAKE_LINES="1 fixup_-C 2" git rebase -i B &&
+ get_author HEAD >actual &&
+ test_cmp expect actual
+'
+
test_expect_success 'simple fixup -c works' '
test_when_finished "test_might_fail git rebase --abort" &&
git checkout --detach A2 &&
@@ -105,9 +114,7 @@ test_expect_success 'fixup -C removes amend! from message' '
FAKE_LINES="1 fixup_-C 2" git rebase -i A &&
test_cmp_rev HEAD^ A &&
test_cmp_rev HEAD^{tree} A1^{tree} &&
- test_commit_message HEAD expected-message &&
- get_author HEAD >actual-author &&
- test_cmp expected-author actual-author
+ test_commit_message HEAD expected-message
'
test_expect_success 'fixup -C with conflicts gives correct message' '
@@ -181,8 +188,6 @@ test_expect_success 'multiple fixup -c opens editor once' '
EXPECT_HEADER_COUNT=4 \
git rebase -i A &&
test_cmp_rev HEAD^ A &&
- get_author HEAD >actual-author &&
- test_cmp expected-author actual-author &&
test_commit_message HEAD expected-message
'
--
2.51.0
^ permalink raw reply related [flat|nested] 14+ messages in thread
* Re: [PATCH] rebase -i: use same commit's message and date with f -C
2025-09-23 8:55 [PATCH] rebase -i: use same commit's message and date with f -C Mathias Rav
@ 2025-09-23 9:21 ` Karthik Nayak
2025-09-23 15:23 ` Phillip Wood
` (4 subsequent siblings)
5 siblings, 0 replies; 14+ messages in thread
From: Karthik Nayak @ 2025-09-23 9:21 UTC (permalink / raw)
To: Mathias Rav, git; +Cc: Junio C Hamano, Phillip Wood
[-- Attachment #1: Type: text/plain, Size: 6144 bytes --]
"Mathias Rav" <m@git.strova.dk> writes:
> In `git rebase -i` with the fixup command, the -C flag controls whether
> the commit message is taken from the previous or current commit,
> 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.
>
Seems fair, and without much insight, this is what I'd assume that the
implementation would be.
> 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.
>
Well explained and makes sense.
> 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>
> ---
>
> I described my own workflow for fixup -C above,
> and it's the only use of fixup -C I'm aware of.
>
> If the current behavior of keeping message from one
> and author from another is useful in someone else's
> workflow, then I'm happy to be enlightened.
>
> Correct author dates are certainly more nice-to-have
> than need-to-have in most git workflows, but I think
> it's worthwhile to have git go the extra mile here.
>
> rebase-interactive.c | 4 ++--
> sequencer.c | 5 +++--
> t/t3437-rebase-fixup-options.sh | 15 ++++++++++-----
> 3 files changed, 15 insertions(+), 9 deletions(-)
>
> diff --git a/rebase-interactive.c b/rebase-interactive.c
> index 809f76a87b..dd303168c2 100644
> --- a/rebase-interactive.c
> +++ b/rebase-interactive.c
> @@ -53,8 +53,8 @@ void append_todo_help(int command_count,
> "s, squash <commit> = use commit, but meld into previous commit\n"
> "f, fixup [-C | -c] <commit> = like \"squash\" but keep only the previous\n"
> " commit's log message, unless -C is used, in which case\n"
> -" keep only this commit's message; -c is same as -C but\n"
> -" opens the editor\n"
> +" keep this commit's message and date; -c is same as -C\n"
I would still keep the `only` word, since that confirms exclusivity.
> +" but opens the editor\n"
> "x, exec <command> = run command (the rest of the line) using shell\n"
> "b, break = stop here (continue rebase later with 'git rebase --continue')\n"
> "d, drop <commit> = remove commit\n"
> diff --git a/sequencer.c b/sequencer.c
> index aaf2e4df64..80209b6b07 100644
> --- a/sequencer.c
> +++ b/sequencer.c
> @@ -1560,7 +1560,8 @@ static int try_to_commit(struct repository *r,
> strbuf_addstr(msg, orig_message);
> hook_commit = "HEAD";
> }
> - author = amend_author = get_author(message);
> + if (!author)
> + author = amend_author = get_author(message);
> repo_unuse_commit_buffer(r, current_head,
> message);
> if (!author) {
> @@ -2419,7 +2420,7 @@ static int do_pick_commit(struct repository *r,
> strbuf_addstr(&ctx->message, oid_to_hex(&commit->object.oid));
> strbuf_addstr(&ctx->message, ")\n");
> }
> - if (!is_fixup(command))
> + if (is_fixup_flag(command, item->flags) || !is_fixup(command))
> author = get_author(msg.message);
If it is not a fixup command or if it is a 'fixup -C', we obtain the
author and pass it on. This makes sense. But what about the commit date?
Don't we have to do something similar there too?
> }
> ctx->have_message = 1;
> diff --git a/t/t3437-rebase-fixup-options.sh b/t/t3437-rebase-fixup-options.sh
> index 5d306a4769..2361d3fb78 100755
> --- a/t/t3437-rebase-fixup-options.sh
> +++ b/t/t3437-rebase-fixup-options.sh
> @@ -85,6 +85,15 @@ test_expect_success 'simple fixup -C works' '
> test_commit_message HEAD -m "A2"
> '
>
> +test_expect_success 'fixup -C keeps second commit date' '
> + test_when_finished "test_might_fail git rebase --abort" &&
> + git checkout --detach A2 &&
> + get_author HEAD >expect &&
> + FAKE_LINES="1 fixup_-C 2" git rebase -i B &&
> + get_author HEAD >actual &&
> + test_cmp expect actual
> +'
Okay, so `get_author` here prints the author name, author email and
author date. Looks good.
> +
> test_expect_success 'simple fixup -c works' '
> test_when_finished "test_might_fail git rebase --abort" &&
> git checkout --detach A2 &&
> @@ -105,9 +114,7 @@ test_expect_success 'fixup -C removes amend! from message' '
> FAKE_LINES="1 fixup_-C 2" git rebase -i A &&
> test_cmp_rev HEAD^ A &&
> test_cmp_rev HEAD^{tree} A1^{tree} &&
> - test_commit_message HEAD expected-message &&
> - get_author HEAD >actual-author &&
> - test_cmp expected-author actual-author
> + test_commit_message HEAD expected-message
> '
>
> test_expect_success 'fixup -C with conflicts gives correct message' '
> @@ -181,8 +188,6 @@ test_expect_success 'multiple fixup -c opens editor once' '
> EXPECT_HEADER_COUNT=4 \
> git rebase -i A &&
> test_cmp_rev HEAD^ A &&
> - get_author HEAD >actual-author &&
> - test_cmp expected-author actual-author &&
> test_commit_message HEAD expected-message
> '
>
> --
> 2.51.0
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 690 bytes --]
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH] rebase -i: use same commit's message and date with f -C
2025-09-23 8:55 [PATCH] rebase -i: use same commit's message and date with f -C Mathias Rav
2025-09-23 9:21 ` Karthik Nayak
@ 2025-09-23 15:23 ` Phillip Wood
2025-09-23 17:10 ` Ben Knoble
` (3 subsequent siblings)
5 siblings, 0 replies; 14+ messages in thread
From: Phillip Wood @ 2025-09-23 15:23 UTC (permalink / raw)
To: Mathias Rav, git; +Cc: Junio C Hamano, Phillip Wood, Karthik Nayak
Hi Mathias
On 23/09/2025 09: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,
> 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.
> > 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.
In that case I'd manually squash the later commit into the split commit
as I don't think you cannot use "rebase --autosquash" to automatically
squash a fixup commit into one of its descendants. I use "fixup -C" to
amend and reword existing commits in the same way that I use an ordinary
"fixup" to amend an existing commit. The only difference is that I'm
rewording the commit message at the same time as I'm possibly changing
the commit content. I use "fixup -C" to expanding the commit message, or
fix typos and want to keep the original commit's authorship as I would
do if I was not changing the commit message.
I think the difference here is that the design of the "fixup" and
"squash" commands assumes that they are fixing up an ancestor, not a
descendant.
Thanks
Phillip
> 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>
> ---
>
> I described my own workflow for fixup -C above,
> and it's the only use of fixup -C I'm aware of.
>
> If the current behavior of keeping message from one
> and author from another is useful in someone else's
> workflow, then I'm happy to be enlightened.
>
> Correct author dates are certainly more nice-to-have
> than need-to-have in most git workflows, but I think
> it's worthwhile to have git go the extra mile here.
>
> rebase-interactive.c | 4 ++--
> sequencer.c | 5 +++--
> t/t3437-rebase-fixup-options.sh | 15 ++++++++++-----
> 3 files changed, 15 insertions(+), 9 deletions(-)
>
> diff --git a/rebase-interactive.c b/rebase-interactive.c
> index 809f76a87b..dd303168c2 100644
> --- a/rebase-interactive.c
> +++ b/rebase-interactive.c
> @@ -53,8 +53,8 @@ void append_todo_help(int command_count,
> "s, squash <commit> = use commit, but meld into previous commit\n"
> "f, fixup [-C | -c] <commit> = like \"squash\" but keep only the previous\n"
> " commit's log message, unless -C is used, in which case\n"
> -" keep only this commit's message; -c is same as -C but\n"
> -" opens the editor\n"
> +" keep this commit's message and date; -c is same as -C\n"
> +" but opens the editor\n"
> "x, exec <command> = run command (the rest of the line) using shell\n"
> "b, break = stop here (continue rebase later with 'git rebase --continue')\n"
> "d, drop <commit> = remove commit\n"
> diff --git a/sequencer.c b/sequencer.c
> index aaf2e4df64..80209b6b07 100644
> --- a/sequencer.c
> +++ b/sequencer.c
> @@ -1560,7 +1560,8 @@ static int try_to_commit(struct repository *r,
> strbuf_addstr(msg, orig_message);
> hook_commit = "HEAD";
> }
> - author = amend_author = get_author(message);
> + if (!author)
> + author = amend_author = get_author(message);
> repo_unuse_commit_buffer(r, current_head,
> message);
> if (!author) {
> @@ -2419,7 +2420,7 @@ static int do_pick_commit(struct repository *r,
> strbuf_addstr(&ctx->message, oid_to_hex(&commit->object.oid));
> strbuf_addstr(&ctx->message, ")\n");
> }
> - if (!is_fixup(command))
> + if (is_fixup_flag(command, item->flags) || !is_fixup(command))
> author = get_author(msg.message);
> }
> ctx->have_message = 1;
> diff --git a/t/t3437-rebase-fixup-options.sh b/t/t3437-rebase-fixup-options.sh
> index 5d306a4769..2361d3fb78 100755
> --- a/t/t3437-rebase-fixup-options.sh
> +++ b/t/t3437-rebase-fixup-options.sh
> @@ -85,6 +85,15 @@ test_expect_success 'simple fixup -C works' '
> test_commit_message HEAD -m "A2"
> '
>
> +test_expect_success 'fixup -C keeps second commit date' '
> + test_when_finished "test_might_fail git rebase --abort" &&
> + git checkout --detach A2 &&
> + get_author HEAD >expect &&
> + FAKE_LINES="1 fixup_-C 2" git rebase -i B &&
> + get_author HEAD >actual &&
> + test_cmp expect actual
> +'
> +
> test_expect_success 'simple fixup -c works' '
> test_when_finished "test_might_fail git rebase --abort" &&
> git checkout --detach A2 &&
> @@ -105,9 +114,7 @@ test_expect_success 'fixup -C removes amend! from message' '
> FAKE_LINES="1 fixup_-C 2" git rebase -i A &&
> test_cmp_rev HEAD^ A &&
> test_cmp_rev HEAD^{tree} A1^{tree} &&
> - test_commit_message HEAD expected-message &&
> - get_author HEAD >actual-author &&
> - test_cmp expected-author actual-author
> + test_commit_message HEAD expected-message
> '
>
> test_expect_success 'fixup -C with conflicts gives correct message' '
> @@ -181,8 +188,6 @@ test_expect_success 'multiple fixup -c opens editor once' '
> EXPECT_HEADER_COUNT=4 \
> git rebase -i A &&
> test_cmp_rev HEAD^ A &&
> - get_author HEAD >actual-author &&
> - test_cmp expected-author actual-author &&
> test_commit_message HEAD expected-message
> '
>
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH] rebase -i: use same commit's message and date with f -C
2025-09-23 8:55 [PATCH] rebase -i: use same commit's message and date with f -C Mathias Rav
2025-09-23 9:21 ` Karthik Nayak
2025-09-23 15:23 ` Phillip Wood
@ 2025-09-23 17:10 ` Ben Knoble
2025-09-23 17:37 ` Kristoffer Haugsbakk
` (2 subsequent siblings)
5 siblings, 0 replies; 14+ messages in thread
From: Ben Knoble @ 2025-09-23 17:10 UTC (permalink / raw)
To: Mathias Rav; +Cc: git, Junio C Hamano, Phillip Wood
> Le 23 sept. 2025 à 04:56, Mathias Rav <m@git.strova.dk> a écrit :
[snip]
> I described my own workflow for fixup -C above,
> and it's the only use of fixup -C I'm aware of.
>
> If the current behavior of keeping message from one
> and author from another is useful in someone else's
> workflow, then I'm happy to be enlightened.
>
> Correct author dates are certainly more nice-to-have
> than need-to-have in most git workflows, but I think
> it's worthwhile to have git go the extra mile here.
I can’t comment on the motivation, but :
> rebase-interactive.c | 4 ++--
> sequencer.c | 5 +++--
> t/t3437-rebase-fixup-options.sh | 15 ++++++++++-----
> 3 files changed, 15 insertions(+), 9 deletions(-)
manual pages need updated also.
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH] rebase -i: use same commit's message and date with f -C
2025-09-23 8:55 [PATCH] rebase -i: use same commit's message and date with f -C Mathias Rav
` (2 preceding siblings ...)
2025-09-23 17:10 ` Ben Knoble
@ 2025-09-23 17:37 ` Kristoffer Haugsbakk
2025-09-23 21:38 ` Junio C Hamano
2025-09-24 16:54 ` Oswald Buddenhagen
5 siblings, 0 replies; 14+ messages in thread
From: Kristoffer Haugsbakk @ 2025-09-23 17:37 UTC (permalink / raw)
To: Mathias Rav, git; +Cc: Junio C Hamano, Phillip Wood
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`?
> 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.
> 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
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH] rebase -i: use same commit's message and date with f -C
2025-09-23 8:55 [PATCH] rebase -i: use same commit's message and date with f -C Mathias Rav
` (3 preceding siblings ...)
2025-09-23 17:37 ` Kristoffer Haugsbakk
@ 2025-09-23 21:38 ` Junio C Hamano
2025-09-24 8:47 ` Johannes Sixt
2025-09-24 16:54 ` Oswald Buddenhagen
5 siblings, 1 reply; 14+ messages in thread
From: Junio C Hamano @ 2025-09-23 21:38 UTC (permalink / raw)
To: Mathias Rav; +Cc: git, Phillip Wood
"Mathias Rav" <m@git.strova.dk> writes:
> In `git rebase -i` with the fixup command, the -C flag controls whether
> the commit message is taken from the previous or current commit,
> but currently the author name, email and date are always taken from the
> previous commit.
As the name of the command says, you are fixing up the previous one,
so I do not find it a problem if the credit for writing the
resulting combined commit stays with the author of the previous one.
The authorship information both covers the contents recorded in the
commit's tree, as well as the commit message.
Granted, many commits of this project that is a one-liner change
often have 50 lines of explanation in the commit log message, but
still I think it is sensible to give more authorship credit to the
author of the contents the tree of the final commit than to the
author of the log message of the final 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.
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.
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH] rebase -i: use same commit's message and date with f -C
2025-09-23 21:38 ` Junio C Hamano
@ 2025-09-24 8:47 ` Johannes Sixt
2025-09-24 13:48 ` Phillip Wood
2025-09-24 15:21 ` Mathias Rav
0 siblings, 2 replies; 14+ messages in thread
From: Johannes Sixt @ 2025-09-24 8:47 UTC (permalink / raw)
To: Junio C Hamano, Mathias Rav; +Cc: git, Phillip Wood
Am 23.09.25 um 23:38 schrieb Junio C Hamano:
> "Mathias Rav" <m@git.strova.dk> writes:
>
>> In `git rebase -i` with the fixup command, the -C flag controls whether
>> the commit message is taken from the previous or current commit,
>> but currently the author name, email and date are always taken from the
>> previous commit.
>
> As the name of the command says, you are fixing up the previous one,
> so I do not find it a problem if the credit for writing the
> resulting combined commit stays with the author of the previous one.
> The authorship information both covers the contents recorded in the
> commit's tree, as well as the commit message.
>
> Granted, many commits of this project that is a one-liner change
> often have 50 lines of explanation in the commit log message, but
> still I think it is sensible to give more authorship credit to the
> author of the contents the tree of the final commit than to the
> author of the log message of the final 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.
>
> 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.
-- Hannes
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH] rebase -i: use same commit's message and date with f -C
2025-09-24 8:47 ` Johannes Sixt
@ 2025-09-24 13:48 ` Phillip Wood
2025-09-24 15:21 ` Mathias Rav
1 sibling, 0 replies; 14+ messages in thread
From: Phillip Wood @ 2025-09-24 13:48 UTC (permalink / raw)
To: Johannes Sixt, Junio C Hamano, Mathias Rav; +Cc: git, Phillip Wood
Hi Johannes
On 24/09/2025 09:47, Johannes Sixt wrote:
>
> 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.
Thanks for explaining that. I had not realized from the commit message
that an important aspect was keeping the commits in order to avoid
conflicts.
> 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.
Or possibly a different option to "fixup" like "--use-author"
Thanks
Phillip
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH] rebase -i: use same commit's message and date with f -C
2025-09-24 8:47 ` Johannes Sixt
2025-09-24 13:48 ` Phillip Wood
@ 2025-09-24 15:21 ` Mathias Rav
2025-09-25 10:11 ` Phillip Wood
1 sibling, 1 reply; 14+ messages in thread
From: Mathias Rav @ 2025-09-24 15:21 UTC (permalink / raw)
To: Johannes Sixt, Junio C Hamano; +Cc: git, Phillip Wood
On Wed, Sep 24, 2025, at 10:47 AM, Johannes Sixt wrote:
> 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.
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH] rebase -i: use same commit's message and date with f -C
2025-09-23 8:55 [PATCH] rebase -i: use same commit's message and date with f -C Mathias Rav
` (4 preceding siblings ...)
2025-09-23 21:38 ` Junio C Hamano
@ 2025-09-24 16:54 ` Oswald Buddenhagen
2025-09-24 20:48 ` Junio C Hamano
5 siblings, 1 reply; 14+ messages in thread
From: Oswald Buddenhagen @ 2025-09-24 16:54 UTC (permalink / raw)
To: Mathias Rav; +Cc: git, Junio C Hamano, Phillip Wood
On Tue, Sep 23, 2025 at 10:55:02AM +0200, Mathias Rav wrote:
>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.
>
related thread: https://lore.kernel.org/git/YjXRM5HiRizZ035p@ugly/T/#u
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH] rebase -i: use same commit's message and date with f -C
2025-09-24 16:54 ` Oswald Buddenhagen
@ 2025-09-24 20:48 ` Junio C Hamano
2025-09-25 10:08 ` Phillip Wood
0 siblings, 1 reply; 14+ messages in thread
From: Junio C Hamano @ 2025-09-24 20:48 UTC (permalink / raw)
To: Oswald Buddenhagen; +Cc: Mathias Rav, git, Phillip Wood
Oswald Buddenhagen <oswald.buddenhagen@gmx.de> writes:
> On Tue, Sep 23, 2025 at 10:55:02AM +0200, Mathias Rav wrote:
>>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.
>>
> related thread: https://lore.kernel.org/git/YjXRM5HiRizZ035p@ugly/T/#u
Thanks. That's a great pointer that shows everybody involved in
this round has pretty much held the same position over the years
;-).
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH] rebase -i: use same commit's message and date with f -C
2025-09-24 20:48 ` Junio C Hamano
@ 2025-09-25 10:08 ` Phillip Wood
0 siblings, 0 replies; 14+ messages in thread
From: Phillip Wood @ 2025-09-25 10:08 UTC (permalink / raw)
To: Junio C Hamano, Oswald Buddenhagen; +Cc: Mathias Rav, git, Phillip Wood
On 24/09/2025 21:48, Junio C Hamano wrote:
> Oswald Buddenhagen <oswald.buddenhagen@gmx.de> writes:
>
>> On Tue, Sep 23, 2025 at 10:55:02AM +0200, Mathias Rav wrote:
>>> 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.
>>>
>> related thread: https://lore.kernel.org/git/YjXRM5HiRizZ035p@ugly/T/#u
>
> Thanks. That's a great pointer that shows everybody involved in
> this round has pretty much held the same position over the years
> ;-).
I'd forgotten we'd discussed this before, thanks for posting the link
Oswald.
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH] rebase -i: use same commit's message and date with f -C
2025-09-24 15:21 ` Mathias Rav
@ 2025-09-25 10:11 ` Phillip Wood
2025-09-25 17:08 ` Junio C Hamano
0 siblings, 1 reply; 14+ messages in thread
From: Phillip Wood @ 2025-09-25 10:11 UTC (permalink / raw)
To: Mathias Rav, Johannes Sixt, Junio C Hamano; +Cc: git, Phillip Wood
Hi Mathias
On 24/09/2025 16:21, Mathias Rav wrote:
>
> 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).
I'd be happy to see a patch that implemented a new option for "fixup"
that copied the author. As the discussion that Oswald linked to shows
this is not the first time someone has wanted this functionality. The
issue is that we don't want to change the existing behavior, not that we
don't want to support this via a different option.
Thanks
Phillip
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH] rebase -i: use same commit's message and date with f -C
2025-09-25 10:11 ` Phillip Wood
@ 2025-09-25 17:08 ` Junio C Hamano
0 siblings, 0 replies; 14+ messages in thread
From: Junio C Hamano @ 2025-09-25 17:08 UTC (permalink / raw)
To: Phillip Wood; +Cc: Mathias Rav, Johannes Sixt, git, Phillip Wood
Phillip Wood <phillip.wood123@gmail.com> writes:
> Hi Mathias
>
> On 24/09/2025 16:21, Mathias Rav wrote:
>> 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).
>
> I'd be happy to see a patch that implemented a new option for "fixup"
> that copied the author. As the discussion that Oswald linked to shows
> this is not the first time someone has wanted this functionality. The
> issue is that we don't want to change the existing behavior, not that
> we don't want to support this via a different option.
Yup, thanks for stating this more clealy than I would.
^ permalink raw reply [flat|nested] 14+ messages in thread
end of thread, other threads:[~2025-09-25 17:08 UTC | newest]
Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-23 8:55 [PATCH] rebase -i: use same commit's message and date with f -C Mathias Rav
2025-09-23 9:21 ` Karthik Nayak
2025-09-23 15:23 ` Phillip Wood
2025-09-23 17:10 ` Ben Knoble
2025-09-23 17:37 ` Kristoffer Haugsbakk
2025-09-23 21:38 ` Junio C Hamano
2025-09-24 8:47 ` Johannes Sixt
2025-09-24 13:48 ` Phillip Wood
2025-09-24 15:21 ` Mathias Rav
2025-09-25 10:11 ` Phillip Wood
2025-09-25 17:08 ` Junio C Hamano
2025-09-24 16:54 ` Oswald Buddenhagen
2025-09-24 20:48 ` Junio C Hamano
2025-09-25 10:08 ` Phillip Wood
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).