{"thread":{"id":"64188","subject":"[PATCH] rebase -i: use same commit's message and date with f -C","startedAt":"2025-09-23T08:55:24Z","lastAt":"2025-09-25T17:08:56Z","messageCount":14,"participants":["Mathias Rav","Karthik Nayak","Phillip Wood","Ben Knoble","Kristoffer Haugsbakk","Junio C Hamano","Johannes Sixt","Oswald Buddenhagen"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"527030","messageId":"92d4d585-09e9-4f1d-a471-1ad6b312fa61@app.fastmail.com","threadId":"64188","inReplyTo":null,"subject":"[PATCH] rebase -i: use same commit's message and date with f -C","fromName":"Mathias Rav","fromEmail":"m@git.strova.dk","sentAt":"2025-09-23T08:55:02Z","receivedAt":"2025-09-23T08:55:24Z","isPatch":true,"sender":{"key":"m@git.strova.dk","avatar":"https://avatars.githubusercontent.com/u/373639?v=4"},"body":"In `git rebase -i` with the fixup command, the -C flag controls whether\nthe commit message is taken from the previous or current commit,\nbut currently the author name, email and date are always taken from the\nprevious commit. The fixup command is used to squash two commits where\none commit has a good message and the other's message does not matter,\nand it is usually also the case that the commit with the good message\nis the one that has the good authorship information; the other is a\nfixup commit that was presumably made by the user moments ago, whereas\nthe commit with the good message is the one whose date should be kept.\n\nMost of the time, a fixup commit is made on top of the commit to be\nfixed up, in which case the rebase -i fixup command is used without -C.\nThe fixup -C case arises when an earlier commit in the branch is split,\nleaving part of the commit to be squashed into a later commit, in which\ncase fixup -C would be expected to keep the date on the later commit,\nand discard the author date of the ephemeral newly split commit.\n\nChange the behavior so that fixup with -C takes both message and author\nfrom the current commit, instead of taking the author from the previous.\n\nTweak try_to_commit to allow specifying author in addition to AMEND_MSG,\nand pass author from the current commit in do_pick_commit in `f -C`.\n\nTweak the help text in `git rebase -i` to reflect the changed behavior.\n\nAdd a test that ensures that the author metadata for the second current\ncommit is kept, and remove some author metadata checks from other tests\nthat now fail since the author metadata is different (as intended).\n\nSigned-off-by: Mathias Rav <m@git.strova.dk>\n---\n\nI described my own workflow for fixup -C above,\nand it's the only use of fixup -C I'm aware of.\n\nIf the current behavior of keeping message from one\nand author from another is useful in someone else's\nworkflow, then I'm happy to be enlightened.\n\nCorrect author dates are certainly more nice-to-have\nthan need-to-have in most git workflows, but I think\nit's worthwhile to have git go the extra mile here.\n\n rebase-interactive.c            |  4 ++--\n sequencer.c                     |  5 +++--\n t/t3437-rebase-fixup-options.sh | 15 ++++++++++-----\n 3 files changed, 15 insertions(+), 9 deletions(-)\n\ndiff --git a/rebase-interactive.c b/rebase-interactive.c\nindex 809f76a87b..dd303168c2 100644\n--- a/rebase-interactive.c\n+++ b/rebase-interactive.c\n@@ -53,8 +53,8 @@ void append_todo_help(int command_count,\n \"s, squash <commit> = use commit, but meld into previous commit\\n\"\n \"f, fixup [-C | -c] <commit> = like \\\"squash\\\" but keep only the previous\\n\"\n \"                   commit's log message, unless -C is used, in which case\\n\"\n-\"                   keep only this commit's message; -c is same as -C but\\n\"\n-\"                   opens the editor\\n\"\n+\"                   keep this commit's message and date; -c is same as -C\\n\"\n+\"                   but opens the editor\\n\"\n \"x, exec <command> = run command (the rest of the line) using shell\\n\"\n \"b, break = stop here (continue rebase later with 'git rebase --continue')\\n\"\n \"d, drop <commit> = remove commit\\n\"\ndiff --git a/sequencer.c b/sequencer.c\nindex aaf2e4df64..80209b6b07 100644\n--- a/sequencer.c\n+++ b/sequencer.c\n@@ -1560,7 +1560,8 @@ static int try_to_commit(struct repository *r,\n \t\t\tstrbuf_addstr(msg, orig_message);\n \t\t\thook_commit = \"HEAD\";\n \t\t}\n-\t\tauthor = amend_author = get_author(message);\n+\t\tif (!author)\n+\t\t\tauthor = amend_author = get_author(message);\n \t\trepo_unuse_commit_buffer(r, current_head,\n \t\t\t\t\t message);\n \t\tif (!author) {\n@@ -2419,7 +2420,7 @@ static int do_pick_commit(struct repository *r,\n \t\t\tstrbuf_addstr(&ctx->message, oid_to_hex(&commit->object.oid));\n \t\t\tstrbuf_addstr(&ctx->message, \")\\n\");\n \t\t}\n-\t\tif (!is_fixup(command))\n+\t\tif (is_fixup_flag(command, item->flags) || !is_fixup(command))\n \t\t\tauthor = get_author(msg.message);\n \t}\n \tctx->have_message = 1;\ndiff --git a/t/t3437-rebase-fixup-options.sh b/t/t3437-rebase-fixup-options.sh\nindex 5d306a4769..2361d3fb78 100755\n--- a/t/t3437-rebase-fixup-options.sh\n+++ b/t/t3437-rebase-fixup-options.sh\n@@ -85,6 +85,15 @@ test_expect_success 'simple fixup -C works' '\n \ttest_commit_message HEAD -m \"A2\"\n '\n \n+test_expect_success 'fixup -C keeps second commit date' '\n+\ttest_when_finished \"test_might_fail git rebase --abort\" &&\n+\tgit checkout --detach A2 &&\n+\tget_author HEAD >expect &&\n+\tFAKE_LINES=\"1 fixup_-C 2\" git rebase -i B &&\n+\tget_author HEAD >actual &&\n+\ttest_cmp expect actual\n+'\n+\n test_expect_success 'simple fixup -c works' '\n \ttest_when_finished \"test_might_fail git rebase --abort\" &&\n \tgit checkout --detach A2 &&\n@@ -105,9 +114,7 @@ test_expect_success 'fixup -C removes amend! from message' '\n \tFAKE_LINES=\"1 fixup_-C 2\" git rebase -i A &&\n \ttest_cmp_rev HEAD^ A &&\n \ttest_cmp_rev HEAD^{tree} A1^{tree} &&\n-\ttest_commit_message HEAD expected-message &&\n-\tget_author HEAD >actual-author &&\n-\ttest_cmp expected-author actual-author\n+\ttest_commit_message HEAD expected-message\n '\n \n test_expect_success 'fixup -C with conflicts gives correct message' '\n@@ -181,8 +188,6 @@ test_expect_success 'multiple fixup -c opens editor once' '\n \t\tEXPECT_HEADER_COUNT=4 \\\n \t\tgit rebase -i A &&\n \ttest_cmp_rev HEAD^ A &&\n-\tget_author HEAD >actual-author &&\n-\ttest_cmp expected-author actual-author &&\n \ttest_commit_message HEAD expected-message\n '\n \n-- \n2.51.0\n\n"},{"id":"527032","messageId":"CAOLa=ZTuJU47DhUE4ix7f17bsspMXnZJWggfgf6WXoOoas+NFw@mail.gmail.com","threadId":"64188","inReplyTo":"92d4d585-09e9-4f1d-a471-1ad6b312fa61@app.fastmail.com","subject":"Re: [PATCH] rebase -i: use same commit's message and date with f -C","fromName":"Karthik Nayak","fromEmail":"karthik.188@gmail.com","sentAt":"2025-09-23T09:21:34Z","receivedAt":"2025-09-23T09:21:37Z","isPatch":true,"sender":{"key":"karthik.188@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1786334?v=4"},"body":"\"Mathias Rav\" <m@git.strova.dk> writes:\n\n> In `git rebase -i` with the fixup command, the -C flag controls whether\n> the commit message is taken from the previous or current commit,\n> but currently the author name, email and date are always taken from the\n> previous commit. The fixup command is used to squash two commits where\n> one commit has a good message and the other's message does not matter,\n> and it is usually also the case that the commit with the good message\n> is the one that has the good authorship information; the other is a\n> fixup commit that was presumably made by the user moments ago, whereas\n> the commit with the good message is the one whose date should be kept.\n>\n\nSeems fair, and without much insight, this is what I'd assume that the\nimplementation would be.\n\n> Most of the time, a fixup commit is made on top of the commit to be\n> fixed up, in which case the rebase -i fixup command is used without -C.\n> The fixup -C case arises when an earlier commit in the branch is split,\n> leaving part of the commit to be squashed into a later commit, in which\n> case fixup -C would be expected to keep the date on the later commit,\n> and discard the author date of the ephemeral newly split commit.\n>\n> Change the behavior so that fixup with -C takes both message and author\n> from the current commit, instead of taking the author from the previous.\n>\n\nWell explained and makes sense.\n\n> Tweak try_to_commit to allow specifying author in addition to AMEND_MSG,\n> and pass author from the current commit in do_pick_commit in `f -C`.\n>\n> Tweak the help text in `git rebase -i` to reflect the changed behavior.\n>\n> Add a test that ensures that the author metadata for the second current\n> commit is kept, and remove some author metadata checks from other tests\n> that now fail since the author metadata is different (as intended).\n>\n> Signed-off-by: Mathias Rav <m@git.strova.dk>\n> ---\n>\n> I described my own workflow for fixup -C above,\n> and it's the only use of fixup -C I'm aware of.\n>\n> If the current behavior of keeping message from one\n> and author from another is useful in someone else's\n> workflow, then I'm happy to be enlightened.\n>\n> Correct author dates are certainly more nice-to-have\n> than need-to-have in most git workflows, but I think\n> it's worthwhile to have git go the extra mile here.\n>\n>  rebase-interactive.c            |  4 ++--\n>  sequencer.c                     |  5 +++--\n>  t/t3437-rebase-fixup-options.sh | 15 ++++++++++-----\n>  3 files changed, 15 insertions(+), 9 deletions(-)\n>\n> diff --git a/rebase-interactive.c b/rebase-interactive.c\n> index 809f76a87b..dd303168c2 100644\n> --- a/rebase-interactive.c\n> +++ b/rebase-interactive.c\n> @@ -53,8 +53,8 @@ void append_todo_help(int command_count,\n>  \"s, squash <commit> = use commit, but meld into previous commit\\n\"\n>  \"f, fixup [-C | -c] <commit> = like \\\"squash\\\" but keep only the previous\\n\"\n>  \"                   commit's log message, unless -C is used, in which case\\n\"\n> -\"                   keep only this commit's message; -c is same as -C but\\n\"\n> -\"                   opens the editor\\n\"\n> +\"                   keep this commit's message and date; -c is same as -C\\n\"\n\nI would still keep the `only` word, since that confirms exclusivity.\n\n> +\"                   but opens the editor\\n\"\n>  \"x, exec <command> = run command (the rest of the line) using shell\\n\"\n>  \"b, break = stop here (continue rebase later with 'git rebase --continue')\\n\"\n>  \"d, drop <commit> = remove commit\\n\"\n> diff --git a/sequencer.c b/sequencer.c\n> index aaf2e4df64..80209b6b07 100644\n> --- a/sequencer.c\n> +++ b/sequencer.c\n> @@ -1560,7 +1560,8 @@ static int try_to_commit(struct repository *r,\n>  \t\t\tstrbuf_addstr(msg, orig_message);\n>  \t\t\thook_commit = \"HEAD\";\n>  \t\t}\n> -\t\tauthor = amend_author = get_author(message);\n> +\t\tif (!author)\n> +\t\t\tauthor = amend_author = get_author(message);\n>  \t\trepo_unuse_commit_buffer(r, current_head,\n>  \t\t\t\t\t message);\n>  \t\tif (!author) {\n> @@ -2419,7 +2420,7 @@ static int do_pick_commit(struct repository *r,\n>  \t\t\tstrbuf_addstr(&ctx->message, oid_to_hex(&commit->object.oid));\n>  \t\t\tstrbuf_addstr(&ctx->message, \")\\n\");\n>  \t\t}\n> -\t\tif (!is_fixup(command))\n> +\t\tif (is_fixup_flag(command, item->flags) || !is_fixup(command))\n>  \t\t\tauthor = get_author(msg.message);\n\nIf it is not a fixup command or if it is a 'fixup -C', we obtain the\nauthor and pass it on. This makes sense. But what about the commit date?\nDon't we have to do something similar there too?\n\n>  \t}\n>  \tctx->have_message = 1;\n> diff --git a/t/t3437-rebase-fixup-options.sh b/t/t3437-rebase-fixup-options.sh\n> index 5d306a4769..2361d3fb78 100755\n> --- a/t/t3437-rebase-fixup-options.sh\n> +++ b/t/t3437-rebase-fixup-options.sh\n> @@ -85,6 +85,15 @@ test_expect_success 'simple fixup -C works' '\n>  \ttest_commit_message HEAD -m \"A2\"\n>  '\n>\n> +test_expect_success 'fixup -C keeps second commit date' '\n> +\ttest_when_finished \"test_might_fail git rebase --abort\" &&\n> +\tgit checkout --detach A2 &&\n> +\tget_author HEAD >expect &&\n> +\tFAKE_LINES=\"1 fixup_-C 2\" git rebase -i B &&\n> +\tget_author HEAD >actual &&\n> +\ttest_cmp expect actual\n> +'\n\nOkay, so `get_author` here prints the author name, author email and\nauthor date. Looks good.\n\n> +\n>  test_expect_success 'simple fixup -c works' '\n>  \ttest_when_finished \"test_might_fail git rebase --abort\" &&\n>  \tgit checkout --detach A2 &&\n> @@ -105,9 +114,7 @@ test_expect_success 'fixup -C removes amend! from message' '\n>  \tFAKE_LINES=\"1 fixup_-C 2\" git rebase -i A &&\n>  \ttest_cmp_rev HEAD^ A &&\n>  \ttest_cmp_rev HEAD^{tree} A1^{tree} &&\n> -\ttest_commit_message HEAD expected-message &&\n> -\tget_author HEAD >actual-author &&\n> -\ttest_cmp expected-author actual-author\n> +\ttest_commit_message HEAD expected-message\n>  '\n>\n>  test_expect_success 'fixup -C with conflicts gives correct message' '\n> @@ -181,8 +188,6 @@ test_expect_success 'multiple fixup -c opens editor once' '\n>  \t\tEXPECT_HEADER_COUNT=4 \\\n>  \t\tgit rebase -i A &&\n>  \ttest_cmp_rev HEAD^ A &&\n> -\tget_author HEAD >actual-author &&\n> -\ttest_cmp expected-author actual-author &&\n>  \ttest_commit_message HEAD expected-message\n>  '\n>\n> --\n> 2.51.0\n"},{"id":"527087","messageId":"1635b82d-a3aa-4b83-8d7b-e415945dbd2e@gmail.com","threadId":"64188","inReplyTo":"92d4d585-09e9-4f1d-a471-1ad6b312fa61@app.fastmail.com","subject":"Re: [PATCH] rebase -i: use same commit's message and date with f -C","fromName":"Phillip Wood","fromEmail":"phillip.wood123@gmail.com","sentAt":"2025-09-23T15:23:47Z","receivedAt":"2025-09-23T15:23:52Z","isPatch":true,"sender":{"key":"phillip.wood@dunelm.org.uk","avatar":null},"body":"Hi Mathias\n\nOn 23/09/2025 09:55, Mathias Rav wrote:\n> In `git rebase -i` with the fixup command, the -C flag controls whether\n> the commit message is taken from the previous or current commit,\n> but currently the author name, email and date are always taken from the\n> previous commit. The fixup command is used to squash two commits where\n> one commit has a good message and the other's message does not matter,\n> and it is usually also the case that the commit with the good message\n> is the one that has the good authorship information; the other is a\n> fixup commit that was presumably made by the user moments ago, whereas\n> the commit with the good message is the one whose date should be kept.\n> > Most of the time, a fixup commit is made on top of the commit to be\n> fixed up, in which case the rebase -i fixup command is used without -C.\n> The fixup -C case arises when an earlier commit in the branch is split,\n> leaving part of the commit to be squashed into a later commit, in which\n> case fixup -C would be expected to keep the date on the later commit,\n> and discard the author date of the ephemeral newly split commit.\n\nIn that case I'd manually squash the later commit into the split commit \nas I don't think you cannot use \"rebase --autosquash\" to automatically \nsquash a fixup commit into one of its descendants. I use \"fixup -C\" to \namend and reword existing commits in the same way that I use an ordinary \n\"fixup\" to amend an existing commit. The only difference is that I'm \nrewording the commit message at the same time as I'm possibly changing \nthe commit content. I use \"fixup -C\" to expanding the commit message, or \nfix typos and want to keep the original commit's authorship as I would \ndo if I was not changing the commit message.\n\nI think the difference here is that the design of the \"fixup\" and \n\"squash\" commands assumes that they are fixing up an ancestor, not a \ndescendant.\n\nThanks\n\nPhillip\n> Change the behavior so that fixup with -C takes both message and author\n> from the current commit, instead of taking the author from the previous.\n> \n> Tweak try_to_commit to allow specifying author in addition to AMEND_MSG,\n> and pass author from the current commit in do_pick_commit in `f -C`.\n> \n> Tweak the help text in `git rebase -i` to reflect the changed behavior.\n> \n> Add a test that ensures that the author metadata for the second current\n> commit is kept, and remove some author metadata checks from other tests\n> that now fail since the author metadata is different (as intended).\n> \n> Signed-off-by: Mathias Rav <m@git.strova.dk>\n> ---\n> \n> I described my own workflow for fixup -C above,\n> and it's the only use of fixup -C I'm aware of.\n> \n> If the current behavior of keeping message from one\n> and author from another is useful in someone else's\n> workflow, then I'm happy to be enlightened.\n> \n> Correct author dates are certainly more nice-to-have\n> than need-to-have in most git workflows, but I think\n> it's worthwhile to have git go the extra mile here.\n> \n>   rebase-interactive.c            |  4 ++--\n>   sequencer.c                     |  5 +++--\n>   t/t3437-rebase-fixup-options.sh | 15 ++++++++++-----\n>   3 files changed, 15 insertions(+), 9 deletions(-)\n> \n> diff --git a/rebase-interactive.c b/rebase-interactive.c\n> index 809f76a87b..dd303168c2 100644\n> --- a/rebase-interactive.c\n> +++ b/rebase-interactive.c\n> @@ -53,8 +53,8 @@ void append_todo_help(int command_count,\n>   \"s, squash <commit> = use commit, but meld into previous commit\\n\"\n>   \"f, fixup [-C | -c] <commit> = like \\\"squash\\\" but keep only the previous\\n\"\n>   \"                   commit's log message, unless -C is used, in which case\\n\"\n> -\"                   keep only this commit's message; -c is same as -C but\\n\"\n> -\"                   opens the editor\\n\"\n> +\"                   keep this commit's message and date; -c is same as -C\\n\"\n> +\"                   but opens the editor\\n\"\n>   \"x, exec <command> = run command (the rest of the line) using shell\\n\"\n>   \"b, break = stop here (continue rebase later with 'git rebase --continue')\\n\"\n>   \"d, drop <commit> = remove commit\\n\"\n> diff --git a/sequencer.c b/sequencer.c\n> index aaf2e4df64..80209b6b07 100644\n> --- a/sequencer.c\n> +++ b/sequencer.c\n> @@ -1560,7 +1560,8 @@ static int try_to_commit(struct repository *r,\n>   \t\t\tstrbuf_addstr(msg, orig_message);\n>   \t\t\thook_commit = \"HEAD\";\n>   \t\t}\n> -\t\tauthor = amend_author = get_author(message);\n> +\t\tif (!author)\n> +\t\t\tauthor = amend_author = get_author(message);\n>   \t\trepo_unuse_commit_buffer(r, current_head,\n>   \t\t\t\t\t message);\n>   \t\tif (!author) {\n> @@ -2419,7 +2420,7 @@ static int do_pick_commit(struct repository *r,\n>   \t\t\tstrbuf_addstr(&ctx->message, oid_to_hex(&commit->object.oid));\n>   \t\t\tstrbuf_addstr(&ctx->message, \")\\n\");\n>   \t\t}\n> -\t\tif (!is_fixup(command))\n> +\t\tif (is_fixup_flag(command, item->flags) || !is_fixup(command))\n>   \t\t\tauthor = get_author(msg.message);\n>   \t}\n>   \tctx->have_message = 1;\n> diff --git a/t/t3437-rebase-fixup-options.sh b/t/t3437-rebase-fixup-options.sh\n> index 5d306a4769..2361d3fb78 100755\n> --- a/t/t3437-rebase-fixup-options.sh\n> +++ b/t/t3437-rebase-fixup-options.sh\n> @@ -85,6 +85,15 @@ test_expect_success 'simple fixup -C works' '\n>   \ttest_commit_message HEAD -m \"A2\"\n>   '\n>   \n> +test_expect_success 'fixup -C keeps second commit date' '\n> +\ttest_when_finished \"test_might_fail git rebase --abort\" &&\n> +\tgit checkout --detach A2 &&\n> +\tget_author HEAD >expect &&\n> +\tFAKE_LINES=\"1 fixup_-C 2\" git rebase -i B &&\n> +\tget_author HEAD >actual &&\n> +\ttest_cmp expect actual\n> +'\n> +\n>   test_expect_success 'simple fixup -c works' '\n>   \ttest_when_finished \"test_might_fail git rebase --abort\" &&\n>   \tgit checkout --detach A2 &&\n> @@ -105,9 +114,7 @@ test_expect_success 'fixup -C removes amend! from message' '\n>   \tFAKE_LINES=\"1 fixup_-C 2\" git rebase -i A &&\n>   \ttest_cmp_rev HEAD^ A &&\n>   \ttest_cmp_rev HEAD^{tree} A1^{tree} &&\n> -\ttest_commit_message HEAD expected-message &&\n> -\tget_author HEAD >actual-author &&\n> -\ttest_cmp expected-author actual-author\n> +\ttest_commit_message HEAD expected-message\n>   '\n>   \n>   test_expect_success 'fixup -C with conflicts gives correct message' '\n> @@ -181,8 +188,6 @@ test_expect_success 'multiple fixup -c opens editor once' '\n>   \t\tEXPECT_HEADER_COUNT=4 \\\n>   \t\tgit rebase -i A &&\n>   \ttest_cmp_rev HEAD^ A &&\n> -\tget_author HEAD >actual-author &&\n> -\ttest_cmp expected-author actual-author &&\n>   \ttest_commit_message HEAD expected-message\n>   '\n>   \n\n"},{"id":"527107","messageId":"BF1B80E7-4DB9-4CDD-9C80-330C4B487DE9@gmail.com","threadId":"64188","inReplyTo":"92d4d585-09e9-4f1d-a471-1ad6b312fa61@app.fastmail.com","subject":"Re: [PATCH] rebase -i: use same commit's message and date with f -C","fromName":"Ben Knoble","fromEmail":"ben.knoble@gmail.com","sentAt":"2025-09-23T17:10:30Z","receivedAt":"2025-09-23T17:10:43Z","isPatch":true,"sender":{"key":"ben.knoble@gmail.com","avatar":"https://avatars.githubusercontent.com/u/22802209?v=4"},"body":"\n> Le 23 sept. 2025 à 04:56, Mathias Rav <m@git.strova.dk> a écrit :\n\n[snip]\n\n> I described my own workflow for fixup -C above,\n> and it's the only use of fixup -C I'm aware of.\n> \n> If the current behavior of keeping message from one\n> and author from another is useful in someone else's\n> workflow, then I'm happy to be enlightened.\n> \n> Correct author dates are certainly more nice-to-have\n> than need-to-have in most git workflows, but I think\n> it's worthwhile to have git go the extra mile here.\n\nI can’t comment on the motivation, but :\n\n> rebase-interactive.c            |  4 ++--\n> sequencer.c                     |  5 +++--\n> t/t3437-rebase-fixup-options.sh | 15 ++++++++++-----\n> 3 files changed, 15 insertions(+), 9 deletions(-)\n\nmanual pages need updated also."},{"id":"527111","messageId":"4e74c0c0-11a8-42bc-a229-196402628b7e@app.fastmail.com","threadId":"64188","inReplyTo":"92d4d585-09e9-4f1d-a471-1ad6b312fa61@app.fastmail.com","subject":"Re: [PATCH] rebase -i: use same commit's message and date with f -C","fromName":"Kristoffer Haugsbakk","fromEmail":"kristofferhaugsbakk@fastmail.com","sentAt":"2025-09-23T17:37:34Z","receivedAt":"2025-09-23T17:37:56Z","isPatch":true,"sender":{"key":"kristofferhaugsbakk@fastmail.com","avatar":null},"body":"On Tue, Sep 23, 2025, at 10:55, Mathias Rav wrote:\n> In `git rebase -i` with the fixup command, the -C flag controls whether\n> the commit message is taken from the previous or current commit,\n\nThat’s also for `fixup -c`.  With `fixup -C` it just also does not open\nthe editor.\n\nMaybe this refers to how `amend!` is changed to `fixup -C`?\n\n> but currently the author name, email and date are always taken from the\n> previous commit. The fixup command is used to squash two commits where\n> one commit has a good message and the other's message does not matter,\n> and it is usually also the case that the commit with the good message\n> is the one that has the good authorship information; the other is a\n> fixup commit that was presumably made by the user moments ago, whereas\n> the commit with the good message is the one whose date should be kept.\n\nI think the rule from the manual\n\n       If you want to fold two or more commits into one, replace the\n       command \"pick\" for the second and subsequent commits with\n       \"squash\" or \"fixup\". If the commits had different authors, the\n       folded commit will be attributed to the author of the first\n       commit. ...\n\nis simple enough.  Adding this exception for `fixup -C` doesn’t \nmake sense to me.\n\nWhy not use `git commit --amend --reset-author --no-edit` in\nthat case?[1]\n\nGranted using `fixup -C` is more advanced interactive use than what I\nget into.\n\n† 1: On author date: I had a commit from the first of June that I got\n    back to.  After rewriting the commit message and adding more things\n    to it the author date still says first of June.  For better or worse\n    this is apparently the “normal” baseline.\n\n> Most of the time, a fixup commit is made on top of the commit to be\n> fixed up, in which case the rebase -i fixup command is used without -C.\n> The fixup -C case arises when an earlier commit in the branch is split,\n> leaving part of the commit to be squashed into a later commit, in which\n> case fixup -C would be expected to keep the date on the later commit,\n> and discard the author date of the ephemeral newly split commit.\n>\n> Change the behavior so that fixup with -C takes both message and author\n> from the current commit, instead of taking the author from the previous.\n>\n> Tweak try_to_commit to allow specifying author in addition to AMEND_MSG,\n> and pass author from the current commit in do_pick_commit in `f -C`.\n>\n> Tweak the help text in `git rebase -i` to reflect the changed behavior.\n>\n> Add a test that ensures that the author metadata for the second current\n> commit is kept, and remove some author metadata checks from other tests\n> that now fail since the author metadata is different (as intended).\n>\n> Signed-off-by: Mathias Rav <m@git.strova.dk>\n> ---\n>[snip]\n\n-- \nKristoffer\n"},{"id":"527157","messageId":"xmqqldm4onma.fsf@gitster.g","threadId":"64188","inReplyTo":"92d4d585-09e9-4f1d-a471-1ad6b312fa61@app.fastmail.com","subject":"Re: [PATCH] rebase -i: use same commit's message and date with f -C","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2025-09-23T21:38:53Z","receivedAt":"2025-09-23T21:38:55Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Mathias Rav\" <m@git.strova.dk> writes:\n\n> In `git rebase -i` with the fixup command, the -C flag controls whether\n> the commit message is taken from the previous or current commit,\n> but currently the author name, email and date are always taken from the\n> previous commit.\n\nAs the name of the command says, you are fixing up the previous one,\nso I do not find it a problem if the credit for writing the\nresulting combined commit stays with the author of the previous one.\nThe authorship information both covers the contents recorded in the\ncommit's tree, as well as the commit message.\n\nGranted, many commits of this project that is a one-liner change\noften have 50 lines of explanation in the commit log message, but\nstill I think it is sensible to give more authorship credit to the\nauthor of the contents the tree of the final commit than to the\nauthor of the log message of the final commit.\n\n> Change the behavior so that fixup with -C takes both message and author\n> from the current commit, instead of taking the author from the previous.\n\nI am somewhat negative to this change.  I am perfectly fine to have\na separate \"I may have started from that previous one, but that was\nso broken that I essentially dismantled the original and replaced\nwith the new one.  It is better to attribute the credit to whoever\ndid this last one that is replacing\" command.  But the \"fixup\"\ncommand people have been familiar with would be different, I would\nthink.\n"},{"id":"527196","messageId":"0a14a93e-7da2-43e1-9d71-c58a69c7a4af@kdbg.org","threadId":"64188","inReplyTo":"xmqqldm4onma.fsf@gitster.g","subject":"Re: [PATCH] rebase -i: use same commit's message and date with f -C","fromName":"Johannes Sixt","fromEmail":"j6t@kdbg.org","sentAt":"2025-09-24T08:47:39Z","receivedAt":"2025-09-24T08:47:49Z","isPatch":true,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"Am 23.09.25 um 23:38 schrieb Junio C Hamano:\n> \"Mathias Rav\" <m@git.strova.dk> writes:\n> \n>> In `git rebase -i` with the fixup command, the -C flag controls whether\n>> the commit message is taken from the previous or current commit,\n>> but currently the author name, email and date are always taken from the\n>> previous commit.\n> \n> As the name of the command says, you are fixing up the previous one,\n> so I do not find it a problem if the credit for writing the\n> resulting combined commit stays with the author of the previous one.\n> The authorship information both covers the contents recorded in the\n> commit's tree, as well as the commit message.\n> \n> Granted, many commits of this project that is a one-liner change\n> often have 50 lines of explanation in the commit log message, but\n> still I think it is sensible to give more authorship credit to the\n> author of the contents the tree of the final commit than to the\n> author of the log message of the final commit.\n> \n>> Change the behavior so that fixup with -C takes both message and author\n>> from the current commit, instead of taking the author from the previous.\n> \n> I am somewhat negative to this change.  I am perfectly fine to have\n> a separate \"I may have started from that previous one, but that was\n> so broken that I essentially dismantled the original and replaced\n> with the new one.  It is better to attribute the credit to whoever\n> did this last one that is replacing\" command.  But the \"fixup\"\n> command people have been familiar with would be different, I would\n> think.\nThe common situation where the proposed change is handy isn't where a\nprevious commit is fixed up.\n\nSometimes, a previous commit is a fixup for a later one, for example, a\nchange slipped into in earlier commit that should go into a later commit\nand has been split off into its own commit. Many times it would be\nsufficient to reorder the commits and be done. However, sometimes (and\nnot even infrequently), reordering the commits introduces conflicts that\ndo not happen if the order remains. Here, we want the proposed feature.\n\nSince your argument hinges on the word and meaning of \"fixup\" (which I\ncan buy somewhat), we could extend \"squash\" with an option that\nspecifies which commit supplies the date and authorship metadata.\n\n-- Hannes\n\n"},{"id":"527213","messageId":"467907a8-06a1-4107-863c-4d0dff0dc9f9@gmail.com","threadId":"64188","inReplyTo":"0a14a93e-7da2-43e1-9d71-c58a69c7a4af@kdbg.org","subject":"Re: [PATCH] rebase -i: use same commit's message and date with f -C","fromName":"Phillip Wood","fromEmail":"phillip.wood123@gmail.com","sentAt":"2025-09-24T13:48:18Z","receivedAt":"2025-09-24T13:48:22Z","isPatch":true,"sender":{"key":"phillip.wood@dunelm.org.uk","avatar":null},"body":"Hi Johannes\n\nOn 24/09/2025 09:47, Johannes Sixt wrote:\n> \n> The common situation where the proposed change is handy isn't where a\n> previous commit is fixed up.\n> \n> Sometimes, a previous commit is a fixup for a later one, for example, a\n> change slipped into in earlier commit that should go into a later commit\n> and has been split off into its own commit. Many times it would be\n> sufficient to reorder the commits and be done. However, sometimes (and\n> not even infrequently), reordering the commits introduces conflicts that\n> do not happen if the order remains. Here, we want the proposed feature.\n\nThanks for explaining that. I had not realized from the commit message \nthat an important aspect was keeping the commits in order to avoid \nconflicts.\n\n> Since your argument hinges on the word and meaning of \"fixup\" (which I\n> can buy somewhat), we could extend \"squash\" with an option that\n> specifies which commit supplies the date and authorship metadata.\n\nOr possibly a different option to \"fixup\" like \"--use-author\"\n\nThanks\n\nPhillip\n\n"},{"id":"527223","messageId":"7de3da11-6191-4fa3-bd0d-842dc45690e7@app.fastmail.com","threadId":"64188","inReplyTo":"0a14a93e-7da2-43e1-9d71-c58a69c7a4af@kdbg.org","subject":"Re: [PATCH] rebase -i: use same commit's message and date with f -C","fromName":"Mathias Rav","fromEmail":"m@git.strova.dk","sentAt":"2025-09-24T15:21:24Z","receivedAt":"2025-09-24T15:22:47Z","isPatch":true,"sender":{"key":"m@git.strova.dk","avatar":"https://avatars.githubusercontent.com/u/373639?v=4"},"body":"On Wed, Sep 24, 2025, at 10:47 AM, Johannes Sixt wrote:\n> Am 23.09.25 um 23:38 schrieb Junio C Hamano:\n>> \"Mathias Rav\" <m@git.strova.dk> writes:\n>>> Change the behavior so that fixup with -C takes both message and author\n>>> from the current commit, instead of taking the author from the previous.\n>> \n>> I am somewhat negative to this change.  I am perfectly fine to have\n>> a separate \"I may have started from that previous one, but that was\n>> so broken that I essentially dismantled the original and replaced\n>> with the new one.  It is better to attribute the credit to whoever\n>> did this last one that is replacing\" command.  But the \"fixup\"\n>> command people have been familiar with would be different, I would\n>> think.\n>\n> The common situation where the proposed change is handy isn't where a\n> previous commit is fixed up.\n>\n> Sometimes, a previous commit is a fixup for a later one, for example, a\n> change slipped into in earlier commit that should go into a later commit\n> and has been split off into its own commit. Many times it would be\n> sufficient to reorder the commits and be done. However, sometimes (and\n> not even infrequently), reordering the commits introduces conflicts that\n> do not happen if the order remains. Here, we want the proposed feature.\n>\n> Since your argument hinges on the word and meaning of \"fixup\" (which I\n> can buy somewhat), we could extend \"squash\" with an option that\n> specifies which commit supplies the date and authorship metadata.\n\nI have never used the \"amend!\" autosquash feature and I was not aware of\nit until I stepped through the code in sequencer.c to implement my\nproposed change. I think the `git commit --amend` manual explains quite\nnicely why you could want to keep the author of one commit and the\nmessage of another.\n\nBefore discovering \"f -C\" to achieve the \"fixdown\" behavior, as Hannes\ndescribes, I used \"x f\" to invoke my own single-letter shell script to\nachieve the behavior I wanted, and I guess I am fine with going back to\nthat for the cases where I want to preserve author dates (which, to be\nfair, is often not that important to me).\n\nFor completeness, the implementation is ~/.local/lib/git-rebase-utils/f\n\n\t#!/bin/sh\n\tgit cherry-pick -n \"$1\" && git commit --amend -nC \"$1\"\n\n...with shell alias git='PATH=~/.local/lib/git-rebase-utils:$PATH \\git'\nallowing \"x f\" in git rebase -i without polluting the regular $PATH.\n"},{"id":"527231","messageId":"aNQiRFbBysXXAPDR@ugly.lan","threadId":"64188","inReplyTo":"92d4d585-09e9-4f1d-a471-1ad6b312fa61@app.fastmail.com","subject":"Re: [PATCH] rebase -i: use same commit's message and date with f -C","fromName":"Oswald Buddenhagen","fromEmail":"oswald.buddenhagen@gmx.de","sentAt":"2025-09-24T16:54:28Z","receivedAt":"2025-09-24T16:54:30Z","isPatch":true,"sender":{"key":"oswald.buddenhagen@gmx.de","avatar":"https://avatars.githubusercontent.com/u/812380?v=4"},"body":"On Tue, Sep 23, 2025 at 10:55:02AM +0200, Mathias Rav wrote:\n>Change the behavior so that fixup with -C takes both message and author\n>from the current commit, instead of taking the author from the previous.\n>\nrelated thread: https://lore.kernel.org/git/YjXRM5HiRizZ035p@ugly/T/#u\n"},{"id":"527259","messageId":"xmqqms6jk25g.fsf@gitster.g","threadId":"64188","inReplyTo":"aNQiRFbBysXXAPDR@ugly.lan","subject":"Re: [PATCH] rebase -i: use same commit's message and date with f -C","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2025-09-24T20:48:27Z","receivedAt":"2025-09-24T20:48:30Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Oswald Buddenhagen <oswald.buddenhagen@gmx.de> writes:\n\n> On Tue, Sep 23, 2025 at 10:55:02AM +0200, Mathias Rav wrote:\n>>Change the behavior so that fixup with -C takes both message and author\n>>from the current commit, instead of taking the author from the previous.\n>>\n> related thread: https://lore.kernel.org/git/YjXRM5HiRizZ035p@ugly/T/#u\n\nThanks.  That's a great pointer that shows everybody involved in\nthis round has pretty much held the same position over the years\n;-).\n"},{"id":"527304","messageId":"1955d836-8b5a-49bd-96b9-5d1c14739b70@gmail.com","threadId":"64188","inReplyTo":"xmqqms6jk25g.fsf@gitster.g","subject":"Re: [PATCH] rebase -i: use same commit's message and date with f -C","fromName":"Phillip Wood","fromEmail":"phillip.wood123@gmail.com","sentAt":"2025-09-25T10:08:23Z","receivedAt":"2025-09-25T10:08:23Z","isPatch":true,"sender":{"key":"phillip.wood@dunelm.org.uk","avatar":null},"body":"On 24/09/2025 21:48, Junio C Hamano wrote:\n> Oswald Buddenhagen <oswald.buddenhagen@gmx.de> writes:\n> \n>> On Tue, Sep 23, 2025 at 10:55:02AM +0200, Mathias Rav wrote:\n>>> Change the behavior so that fixup with -C takes both message and author\n>> >from the current commit, instead of taking the author from the previous.\n>>>\n>> related thread: https://lore.kernel.org/git/YjXRM5HiRizZ035p@ugly/T/#u\n> \n> Thanks.  That's a great pointer that shows everybody involved in\n> this round has pretty much held the same position over the years\n> ;-).\n\nI'd forgotten we'd discussed this before, thanks for posting the link \nOswald.\n\n"},{"id":"527305","messageId":"12659f80-2934-4158-9a22-7a4c11060679@gmail.com","threadId":"64188","inReplyTo":"7de3da11-6191-4fa3-bd0d-842dc45690e7@app.fastmail.com","subject":"Re: [PATCH] rebase -i: use same commit's message and date with f -C","fromName":"Phillip Wood","fromEmail":"phillip.wood123@gmail.com","sentAt":"2025-09-25T10:11:56Z","receivedAt":"2025-09-25T10:11:56Z","isPatch":true,"sender":{"key":"phillip.wood@dunelm.org.uk","avatar":null},"body":"Hi Mathias\n\nOn 24/09/2025 16:21, Mathias Rav wrote:\n> \n> I have never used the \"amend!\" autosquash feature and I was not aware of\n> it until I stepped through the code in sequencer.c to implement my\n> proposed change. I think the `git commit --amend` manual explains quite\n> nicely why you could want to keep the author of one commit and the\n> message of another.\n> \n> Before discovering \"f -C\" to achieve the \"fixdown\" behavior, as Hannes\n> describes, I used \"x f\" to invoke my own single-letter shell script to\n> achieve the behavior I wanted, and I guess I am fine with going back to\n> that for the cases where I want to preserve author dates (which, to be\n> fair, is often not that important to me).\n\nI'd be happy to see a patch that implemented a new option for \"fixup\" \nthat copied the author. As the discussion that Oswald linked to shows \nthis is not the first time someone has wanted this functionality. The \nissue is that we don't want to change the existing behavior, not that we \ndon't want to support this via a different option.\n\nThanks\n\nPhillip\n\n"},{"id":"527340","messageId":"xmqq7bxmh32z.fsf@gitster.g","threadId":"64188","inReplyTo":"12659f80-2934-4158-9a22-7a4c11060679@gmail.com","subject":"Re: [PATCH] rebase -i: use same commit's message and date with f -C","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2025-09-25T17:08:52Z","receivedAt":"2025-09-25T17:08:56Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Phillip Wood <phillip.wood123@gmail.com> writes:\n\n> Hi Mathias\n>\n> On 24/09/2025 16:21, Mathias Rav wrote:\n>> I have never used the \"amend!\" autosquash feature and I was not\n>> aware of\n>> it until I stepped through the code in sequencer.c to implement my\n>> proposed change. I think the `git commit --amend` manual explains quite\n>> nicely why you could want to keep the author of one commit and the\n>> message of another.\n>> Before discovering \"f -C\" to achieve the \"fixdown\" behavior, as\n>> Hannes\n>> describes, I used \"x f\" to invoke my own single-letter shell script to\n>> achieve the behavior I wanted, and I guess I am fine with going back to\n>> that for the cases where I want to preserve author dates (which, to be\n>> fair, is often not that important to me).\n>\n> I'd be happy to see a patch that implemented a new option for \"fixup\"\n> that copied the author. As the discussion that Oswald linked to shows\n> this is not the first time someone has wanted this functionality. The\n> issue is that we don't want to change the existing behavior, not that\n> we don't want to support this via a different option.\n\nYup, thanks for stating this more clealy than I would.\n"}]}