{"thread":{"id":"64996","subject":"[PATCH] format-patch: fix from header in cover letter","startedAt":"2026-02-14T05:58:31Z","lastAt":"2026-02-20T18:11:41Z","messageCount":17,"participants":["Mirko Faina","Junio C Hamano","Patrick Steinhardt","Jeff King","D. Ben Knoble","Mroik"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"536001","messageId":"aZAMr6XOwKkTa55q@exploit","threadId":"64996","inReplyTo":null,"subject":"[PATCH] format-patch: fix from header in cover letter","fromName":"Mirko Faina","fromEmail":"mroik@delayed.space","sentAt":"2026-02-14T05:49:23Z","receivedAt":"2026-02-14T05:58:31Z","isPatch":true,"sender":{"key":"mroik@delayed.space","avatar":"https://avatars.githubusercontent.com/u/25752903?v=4"},"body":"From: Mroik <mroik@delayed.space>\n\nFixes \"From\" header for the cover letter when `--from` is passed\n\nSigned-off-by: Mroik <mroik@delayed.space>\n---\n builtin/log.c | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/builtin/log.c b/builtin/log.c\nindex d43ca693bf..df41b43fce 100644\n--- a/builtin/log.c\n+++ b/builtin/log.c\n@@ -1345,7 +1345,7 @@ static void make_cover_letter(struct rev_info *rev, int use_separate_file,\n \tif (!cmit_fmt_is_mail(rev->commit_format))\n \t\tdie(_(\"cover letter needs email format\"));\n \n-\tcommitter = git_committer_info(0);\n+\tcommitter = cfg->from ? cfg->from : git_committer_info(0);\n \n \tif (use_separate_file &&\n \t    open_next_file(NULL, rev->numbered_files ? NULL : \"cover-letter\", rev, quiet))\n-- \n2.53.0\n"},{"id":"536095","messageId":"xmqqv7fxdkay.fsf@gitster.g","threadId":"64996","inReplyTo":"aZAMr6XOwKkTa55q@exploit","subject":"Re: [PATCH] format-patch: fix from header in cover letter","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2026-02-16T11:01:09Z","receivedAt":"2026-02-16T11:01:12Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Mirko Faina <mroik@delayed.space> writes:\n\n> Subject: Re: [PATCH] format-patch: fix from header in cover letter\n\nThanks.  That reads well.\n\n> From: Mroik <mroik@delayed.space>\n\nThe ident used here matches what is used on the signed-off-by line,\nwhich is good.  We tend to prefer people to use their real names,\nthough (and I suspect that your name probably has some multi-word\nstructure, not a single-word).\n\n> Fixes \"From\" header for the cover letter when `--from` is passed\n\nThe usual way to compose a log message of this project is to\n\n - Give an observation on how the current system works in the\n   present tense (so no need to say \"Currently X is Y\", or\n   \"Previously X was Y\" to describe the state before your change;\n   just \"X is Y\" is enough), and discuss what you perceive as a\n   problem in it.\n\n - Propose a solution (optional---often, problem description\n   trivially leads to an obvious solution in reader's minds).\n\n - Give commands to somebody editing the codebase to \"make it so\",\n   instead of saying \"This commit does X\".\n\nin this order.  I am guessing that the problem you are fixing, which\nis not said explicitly in what you wrote, is that even when you run\n\"git format-patch --from='Me <me@my.address>'\", the option is not\nused for cover letter?  If that is the case, perhaps I'd write\nsomething along this line:\n\n    \"git format-patch\" takes \"--from=<user ident>\" command line\n    option, and the given ident is used for patch e-mails, but for\n    the cover letter e-mail, the option is ignored and the committer\n    ident of the current user is used.\n\n    Teach the make_cover_letter() function to honor the option,\n    instead of always using the current committer identity.\n\nif I were making this change.\n\n> Signed-off-by: Mroik <mroik@delayed.space>\n\nAgain, the ident used here matches what is used on the in-body From:\nline, which is good.\n\n> ---\n>  builtin/log.c | 2 +-\n>  1 file changed, 1 insertion(+), 1 deletion(-)\n\nThis can be tested easily without flakes, so we should add some test\nin one of the t/t*-format-patch*.sh files to help people notice when\nthey breaks this fix by mistake in the future.\n\n> diff --git a/builtin/log.c b/builtin/log.c\n> index d43ca693bf..df41b43fce 100644\n> --- a/builtin/log.c\n> +++ b/builtin/log.c\n> @@ -1345,7 +1345,7 @@ static void make_cover_letter(struct rev_info *rev, int use_separate_file,\n>  \tif (!cmit_fmt_is_mail(rev->commit_format))\n>  \t\tdie(_(\"cover letter needs email format\"));\n>  \n> -\tcommitter = git_committer_info(0);\n> +\tcommitter = cfg->from ? cfg->from : git_committer_info(0);\n\nThis is a correct and minimal change, but if I were making this\nchange, I'd probably rename the \"committer\" variable.  Before the\n\"--from\" option came into play, the function has always assumed that\nit should make the cover letter message from the current user, using\ntheir committer ident, which meant that the \"From:\" address and the\ncommitter ident were synonymous from this function's point of view.\n\nBut now we are telling the function that its assumption is no longer\ngood, and teaching it to honor the \"From:\" address given in the cfg.\nAnd the way this local variable is used is to point at a string that\nis the ident used for the \"From:\" address, which is not necessarily\nthe same as committer ident in this new world order.  So it is not\nreader-friendly to keep using \"committer\" as the name of the\nvariable.  Simply call it \"from\", perhaps?\n\n>  \tif (use_separate_file &&\n>  \t    open_next_file(NULL, rev->numbered_files ? NULL : \"cover-letter\", rev, quiet))\n\nThanks.\n"},{"id":"536107","messageId":"20260216152730.37478-1-mroik@delayed.space","threadId":"64996","inReplyTo":"aZAMr6XOwKkTa55q@exploit","subject":"[PATCH v2] format-patch: fix From header in cover letter","fromName":"Mirko Faina","fromEmail":"mroik@delayed.space","sentAt":"2026-02-16T15:27:30Z","receivedAt":"2026-02-16T15:28:21Z","isPatch":true,"sender":{"key":"mroik@delayed.space","avatar":"https://avatars.githubusercontent.com/u/25752903?v=4"},"body":"\"git format-patch\" takes \"--from=<user ident>\" command line option and\nuses the given ident for patch e-mails, but this is not applied to the\ncover letter, the option is ignored and the committer ident of the\ncurrent user is used.\n\nTeach the make_cover_letter() function to honor the option, instead of\nalways using the current committer identity.\n\nSigned-off-by: Mirko Faina <mroik@delayed.space>\n---\nI'm sorry about the poor quality of the previous commit message, I\nrealise it did a poor job at explaining what the patch did.\n\nI've applied the changes you suggested and wrote the test.\nThank you for the review.\n\n builtin/log.c           |  6 +++---\n t/t4014-format-patch.sh | 12 ++++++++++++\n 2 files changed, 15 insertions(+), 3 deletions(-)\n\ndiff --git a/builtin/log.c b/builtin/log.c\nindex d43ca693bf..42648dda54 100644\n--- a/builtin/log.c\n+++ b/builtin/log.c\n@@ -1332,7 +1332,7 @@ static void make_cover_letter(struct rev_info *rev, int use_separate_file,\n \t\t\t      int quiet,\n \t\t\t      const struct format_config *cfg)\n {\n-\tconst char *committer;\n+\tconst char *from;\n \tstruct shortlog log;\n \tstruct strbuf sb = STRBUF_INIT;\n \tint i;\n@@ -1345,7 +1345,7 @@ static void make_cover_letter(struct rev_info *rev, int use_separate_file,\n \tif (!cmit_fmt_is_mail(rev->commit_format))\n \t\tdie(_(\"cover letter needs email format\"));\n \n-\tcommitter = git_committer_info(0);\n+\tfrom = cfg->from ? cfg->from : git_committer_info(0);\n \n \tif (use_separate_file &&\n \t    open_next_file(NULL, rev->numbered_files ? NULL : \"cover-letter\", rev, quiet))\n@@ -1368,7 +1368,7 @@ static void make_cover_letter(struct rev_info *rev, int use_separate_file,\n \tpp.date_mode.type = DATE_RFC2822;\n \tpp.rev = rev;\n \tpp.encode_email_headers = rev->encode_email_headers;\n-\tpp_user_info(&pp, NULL, &sb, committer, encoding);\n+\tpp_user_info(&pp, NULL, &sb, from, encoding);\n \tprepare_cover_text(&pp, description_file, branch_name, &sb,\n \t\t\t   encoding, need_8bit_cte, cfg);\n \tfprintf(rev->diffopt.file, \"%s\\n\", sb.buf);\ndiff --git a/t/t4014-format-patch.sh b/t/t4014-format-patch.sh\nindex 21d6d0cd9e..cb04a9c47b 100755\n--- a/t/t4014-format-patch.sh\n+++ b/t/t4014-format-patch.sh\n@@ -1472,6 +1472,18 @@ test_expect_success '--from uses committer ident' '\n \ttest_cmp expect patch.head\n '\n \n+test_expect_success '--from applies to cover letter' '\n+\techo \"This is a test text\" >file_to_commit &&\n+\tgit format-patch -1 --stdout --cover-letter --from=\"Foo Bar <author@example.com>\" >patch &&\n+\tcat >expect <<-\\EOF &&\n+\tFrom: Foo Bar <author@example.com>\n+\tFrom: Foo Bar <author@example.com>\n+\tFrom: A U Thor <author@example.com>\n+\tEOF\n+\tsed -ne \"/^From:/p; /^[[:space:]]$/d\" patch >patch.head &&\n+\ttest_cmp expect patch.head\n+'\n+\n test_expect_success '--from omits redundant in-body header' '\n \tgit format-patch -1 --stdout --from=\"A U Thor <author@example.com>\" >patch &&\n \tcat >expect <<-\\EOF &&\n-- \n2.53.0\n\n"},{"id":"536141","messageId":"aZQJEDyUyMv4_c1l@pks.im","threadId":"64996","inReplyTo":"20260216152730.37478-1-mroik@delayed.space","subject":"Re: [PATCH v2] format-patch: fix From header in cover letter","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2026-02-17T06:22:08Z","receivedAt":"2026-02-17T06:22:15Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"On Mon, Feb 16, 2026 at 04:27:30PM +0100, Mirko Faina wrote:\n> \"git format-patch\" takes \"--from=<user ident>\" command line option and\n> uses the given ident for patch e-mails, but this is not applied to the\n> cover letter, the option is ignored and the committer ident of the\n> current user is used.\n\nI think it makes sense to apply this identity to the cover letter, as\nwell. After all, I would say that the whole intent is to allow the user\nto send those mails from their own mail address, and of course that\nwould also require us to send the cover letter from that address.\n\nOne thing that made me stop though is the folowing sentence in\ngit-format-patch(1):\n\n  Use ident in the From: header of each commit email.\n\nThe option explicitly mentions that we use \"--from\" for the commit\nemails, only, and that may be read as implying that it's not used for\nthe cover letter.\n\nI don't really know whether that wording is intentional, and I cannot\ncome up with a good reason why it should be. But I'd say that the\nwording is something we should adjust.\n\n> diff --git a/builtin/log.c b/builtin/log.c\n> index d43ca693bf..42648dda54 100644\n> --- a/builtin/log.c\n> +++ b/builtin/log.c\n> @@ -1332,7 +1332,7 @@ static void make_cover_letter(struct rev_info *rev, int use_separate_file,\n>  \t\t\t      int quiet,\n>  \t\t\t      const struct format_config *cfg)\n>  {\n> -\tconst char *committer;\n> +\tconst char *from;\n>  \tstruct shortlog log;\n>  \tstruct strbuf sb = STRBUF_INIT;\n>  \tint i;\n> @@ -1345,7 +1345,7 @@ static void make_cover_letter(struct rev_info *rev, int use_separate_file,\n>  \tif (!cmit_fmt_is_mail(rev->commit_format))\n>  \t\tdie(_(\"cover letter needs email format\"));\n>  \n> -\tcommitter = git_committer_info(0);\n> +\tfrom = cfg->from ? cfg->from : git_committer_info(0);\n>  \n>  \tif (use_separate_file &&\n>  \t    open_next_file(NULL, rev->numbered_files ? NULL : \"cover-letter\", rev, quiet))\n> @@ -1368,7 +1368,7 @@ static void make_cover_letter(struct rev_info *rev, int use_separate_file,\n>  \tpp.date_mode.type = DATE_RFC2822;\n>  \tpp.rev = rev;\n>  \tpp.encode_email_headers = rev->encode_email_headers;\n> -\tpp_user_info(&pp, NULL, &sb, committer, encoding);\n> +\tpp_user_info(&pp, NULL, &sb, from, encoding);\n>  \tprepare_cover_text(&pp, description_file, branch_name, &sb,\n>  \t\t\t   encoding, need_8bit_cte, cfg);\n>  \tfprintf(rev->diffopt.file, \"%s\\n\", sb.buf);\n\nThe changes here look straight forward.\n\n> diff --git a/t/t4014-format-patch.sh b/t/t4014-format-patch.sh\n> index 21d6d0cd9e..cb04a9c47b 100755\n> --- a/t/t4014-format-patch.sh\n> +++ b/t/t4014-format-patch.sh\n> @@ -1472,6 +1472,18 @@ test_expect_success '--from uses committer ident' '\n>  \ttest_cmp expect patch.head\n>  '\n>  \n> +test_expect_success '--from applies to cover letter' '\n> +\techo \"This is a test text\" >file_to_commit &&\n\nThis file isn't used.\n\n> +\tgit format-patch -1 --stdout --cover-letter --from=\"Foo Bar <author@example.com>\" >patch &&\n> +\tcat >expect <<-\\EOF &&\n> +\tFrom: Foo Bar <author@example.com>\n> +\tFrom: Foo Bar <author@example.com>\n> +\tFrom: A U Thor <author@example.com>\n> +\tEOF\n> +\tsed -ne \"/^From:/p; /^[[:space:]]$/d\" patch >patch.head &&\n> +\ttest_cmp expect patch.head\n> +'\n\nWe're not only testing the cover letter here though, but also the other\ngenerated patch. This makes it somewhat hard to verify that the test\nactually works as expected. Would it make sense to maybe use something\nlike the following instead?\n\n  test_expect_success '--from applies to cover letter' '\n  \ttest_when_finished \"rm -rf patches\" &&\n  \tgit format-patch -1 --cover-letter --from=\"Foo Bar <author@example.com>\" -o patches &&\n  \techo \"From: Foo Bar <author@example.com>\" >expect &&\n  \tgrep \"^From:\" patches/0000-cover-letter.patch >patch.head &&\n  \ttest_cmp expect patch.head\n  '\n\nThanks!\n\nPatrick\n"},{"id":"536142","messageId":"20260217063400.GA101988@coredump.intra.peff.net","threadId":"64996","inReplyTo":"aZQJEDyUyMv4_c1l@pks.im","subject":"Re: [PATCH v2] format-patch: fix From header in cover letter","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2026-02-17T06:34:00Z","receivedAt":"2026-02-17T06:34:08Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Tue, Feb 17, 2026 at 07:22:08AM +0100, Patrick Steinhardt wrote:\n\n> One thing that made me stop though is the folowing sentence in\n> git-format-patch(1):\n> \n>   Use ident in the From: header of each commit email.\n> \n> The option explicitly mentions that we use \"--from\" for the commit\n> emails, only, and that may be read as implying that it's not used for\n> the cover letter.\n> \n> I don't really know whether that wording is intentional, and I cannot\n> come up with a good reason why it should be. But I'd say that the\n> wording is something we should adjust.\n\nI think that wording comes from me back in 2013, and I just never gave\nany thought to cover-letter generation by format-patch itself. I never\nuse it (and I probably forgot it even existed, given that most people\nwould use send-email's cover letter generation, and I do my own thing\nwith mutt).\n\nSo I think the direction of the patch is good, and I agree it would make\nsense to clarify the documentation.\n\n-Peff\n"},{"id":"536180","messageId":"CALnO6CD6c36ur4cxqNAB=Jy=m6yxVfoSzAAekewQZr2vjjKn2w@mail.gmail.com","threadId":"64996","inReplyTo":"20260217063400.GA101988@coredump.intra.peff.net","subject":"Re: [PATCH v2] format-patch: fix From header in cover letter","fromName":"D. Ben Knoble","fromEmail":"ben.knoble@gmail.com","sentAt":"2026-02-17T13:21:32Z","receivedAt":"2026-02-17T13:21:44Z","isPatch":true,"sender":{"key":"ben.knoble@gmail.com","avatar":"https://avatars.githubusercontent.com/u/22802209?v=4"},"body":"On Tue, Feb 17, 2026 at 1:34 AM Jeff King <peff@peff.net> wrote:\n>\n> On Tue, Feb 17, 2026 at 07:22:08AM +0100, Patrick Steinhardt wrote:\n>\n> > One thing that made me stop though is the folowing sentence in\n> > git-format-patch(1):\n> >\n> >   Use ident in the From: header of each commit email.\n> >\n> > The option explicitly mentions that we use \"--from\" for the commit\n> > emails, only, and that may be read as implying that it's not used for\n> > the cover letter.\n> >\n> > I don't really know whether that wording is intentional, and I cannot\n> > come up with a good reason why it should be. But I'd say that the\n> > wording is something we should adjust.\n>\n> I think that wording comes from me back in 2013, and I just never gave\n> any thought to cover-letter generation by format-patch itself. I never\n> use it (and I probably forgot it even existed, given that most people\n> would use send-email's cover letter generation, and I do my own thing\n> with mutt).\n\nFunny: the send-email manual's main mention of cover letters apart\nfrom setting Cc/To fields is in an example…\n\n           $ git format-patch --cover-letter -M origin/master -o outgoing/\n           $ edit outgoing/0000-*\n           $ git send-email outgoing/*\n\n…using format-patch! (Which is how I generate cover letters, and\nprobably part of why.)\n\n-- \nD. Ben Knoble\n"},{"id":"536193","messageId":"xmqqecmje6o6.fsf@gitster.g","threadId":"64996","inReplyTo":"20260217063400.GA101988@coredump.intra.peff.net","subject":"Re: [PATCH v2] format-patch: fix From header in cover letter","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2026-02-17T15:22:33Z","receivedAt":"2026-02-17T15:22:35Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jeff King <peff@peff.net> writes:\n\n> I think that wording comes from me back in 2013, and I just never gave\n> any thought to cover-letter generation by format-patch itself.\n\nFigures.  If \"--from\" was done by somebody who did not know or care\nabout the cover letter, it is totally understandable omission the\npatch addresses.  The log message may want to refer to a9080475\n(teach format-patch to place other authors into in-body \"From\",\n2013-07-03).\n\n> I never\n> use it (and I probably forgot it even existed, given that most people\n> would use send-email's cover letter generation, and I do my own thing\n> with mutt).\n\nI use it myself and I really hate the way it lists the patches.  We\nshould have done \"log --oneline --reverse\" instead of \"shortlog\", as\nit is hard to understand the reference the cover letter message\nmakes to individual patches like \"the first two patches do X\", etc.\n\n> So I think the direction of the patch is good, and I agree it would make\n> sense to clarify the documentation.\n\nYes.  It does make sense to document the change in thinking in the\nproposed log message and in documentation.\n\nThanks.\n\n"},{"id":"536231","messageId":"20260217220515.14127-1-mroik@delayed.space","threadId":"64996","inReplyTo":"20260216152730.37478-1-mroik@delayed.space","subject":"[PATCH] format-patch: fix From header in cover letter","fromName":"Mroik","fromEmail":"mroik@delayed.space","sentAt":"2026-02-17T22:04:39Z","receivedAt":"2026-02-17T22:06:04Z","isPatch":true,"sender":{"key":"mroik@delayed.space","avatar":"https://avatars.githubusercontent.com/u/25752903?v=4"},"body":"From: Mirko Faina <mroik@delayed.space>\n\n\"git format-patch\" takes \"--from=<user ident>\" command line option and\nuses the given ident for patch e-mails, but this is not applied to the\ncover letter, the option is ignored and the committer ident of the\ncurrent user is used.\n\nTeach the make_cover_letter() function to honor the option, instead of\nalways using the current committer identity.\n\nSigned-off-by: Mirko Faina <mroik@delayed.space>\n---\n Documentation/git-format-patch.adoc | 10 +++++-----\n builtin/log.c                       |  6 +++---\n t/t4014-format-patch.sh             |  8 ++++++++\n 3 files changed, 16 insertions(+), 8 deletions(-)\n\ndiff --git a/Documentation/git-format-patch.adoc b/Documentation/git-format-patch.adoc\nindex 9a7807ca71..05c4192dbc 100644\n--- a/Documentation/git-format-patch.adoc\n+++ b/Documentation/git-format-patch.adoc\n@@ -282,11 +282,11 @@ e.g., `--rfc='-(WIP)'` results in \"PATCH (WIP)\".\n \n --from::\n --from=<ident>::\n-\tUse `ident` in the `From:` header of each commit email. If the\n-\tauthor ident of the commit is not textually identical to the\n-\tprovided `ident`, place a `From:` header in the body of the\n-\tmessage with the original author. If no `ident` is given, use\n-\tthe committer ident.\n+\tUse `ident` in the `From:` header of each email. In case of a\n+\tcommit email, if the author ident of the commit is not textually\n+\tidentical to the provided `ident`, place a `From:` header in the\n+\tbody of the message with the original author. If no `ident` is\n+\tgiven, use the committer ident.\n +\n Note that this option is only useful if you are actually sending the\n emails and want to identify yourself as the sender, but retain the\ndiff --git a/builtin/log.c b/builtin/log.c\nindex d43ca693bf..42648dda54 100644\n--- a/builtin/log.c\n+++ b/builtin/log.c\n@@ -1332,7 +1332,7 @@ static void make_cover_letter(struct rev_info *rev, int use_separate_file,\n \t\t\t      int quiet,\n \t\t\t      const struct format_config *cfg)\n {\n-\tconst char *committer;\n+\tconst char *from;\n \tstruct shortlog log;\n \tstruct strbuf sb = STRBUF_INIT;\n \tint i;\n@@ -1345,7 +1345,7 @@ static void make_cover_letter(struct rev_info *rev, int use_separate_file,\n \tif (!cmit_fmt_is_mail(rev->commit_format))\n \t\tdie(_(\"cover letter needs email format\"));\n \n-\tcommitter = git_committer_info(0);\n+\tfrom = cfg->from ? cfg->from : git_committer_info(0);\n \n \tif (use_separate_file &&\n \t    open_next_file(NULL, rev->numbered_files ? NULL : \"cover-letter\", rev, quiet))\n@@ -1368,7 +1368,7 @@ static void make_cover_letter(struct rev_info *rev, int use_separate_file,\n \tpp.date_mode.type = DATE_RFC2822;\n \tpp.rev = rev;\n \tpp.encode_email_headers = rev->encode_email_headers;\n-\tpp_user_info(&pp, NULL, &sb, committer, encoding);\n+\tpp_user_info(&pp, NULL, &sb, from, encoding);\n \tprepare_cover_text(&pp, description_file, branch_name, &sb,\n \t\t\t   encoding, need_8bit_cte, cfg);\n \tfprintf(rev->diffopt.file, \"%s\\n\", sb.buf);\ndiff --git a/t/t4014-format-patch.sh b/t/t4014-format-patch.sh\nindex 21d6d0cd9e..2135b65cee 100755\n--- a/t/t4014-format-patch.sh\n+++ b/t/t4014-format-patch.sh\n@@ -1472,6 +1472,14 @@ test_expect_success '--from uses committer ident' '\n \ttest_cmp expect patch.head\n '\n \n+test_expect_success '--from applies to cover letter' '\n+\ttest_when_finished \"rm -rf patches\" &&\n+\tgit format-patch -1 --cover-letter --from=\"Foo Bar <author@example.com>\" -o patches &&\n+\techo \"From: Foo Bar <author@example.com>\" >expect &&\n+\tgrep \"^From:\" patches/0000-cover-letter.patch >patch.head &&\n+\ttest_cmp expect patch.head\n+'\n+\n test_expect_success '--from omits redundant in-body header' '\n \tgit format-patch -1 --stdout --from=\"A U Thor <author@example.com>\" >patch &&\n \tcat >expect <<-\\EOF &&\n-- \n2.53.0\n\n"},{"id":"536232","messageId":"aZTnmXcLm1MNcIxO@exploit","threadId":"64996","inReplyTo":"20260217220515.14127-1-mroik@delayed.space","subject":"Re: [PATCH] format-patch: fix From header in cover letter","fromName":"Mirko Faina","fromEmail":"mroik@delayed.space","sentAt":"2026-02-17T22:13:21Z","receivedAt":"2026-02-17T22:13:25Z","isPatch":true,"sender":{"key":"mroik@delayed.space","avatar":"https://avatars.githubusercontent.com/u/25752903?v=4"},"body":"I'm sorry, I forgot to mark as v3 and to change the sender name.\n"},{"id":"536233","messageId":"xmqq7bsb9emn.fsf@gitster.g","threadId":"64996","inReplyTo":"20260217220515.14127-1-mroik@delayed.space","subject":"Re: [PATCH] format-patch: fix From header in cover letter","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2026-02-17T22:41:52Z","receivedAt":"2026-02-17T22:41:55Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Mroik <mroik@delayed.space> writes:\n\n> From: Mirko Faina <mroik@delayed.space>\n>\n> \"git format-patch\" takes \"--from=<user ident>\" command line option and\n> uses the given ident for patch e-mails, but this is not applied to the\n> cover letter, the option is ignored and the committer ident of the\n> current user is used.\n\nIt is worth noting that ever since this \"--from\" option was\nintroduced, it was not used when generating the cover letter in the\nproposed log message in the above paragraph somewhere.\n\n> Teach the make_cover_letter() function to honor the option, instead of\n> always using the current committer identity.\n\nAlso the reasoning behind the rename of \"committer\" to \"from\" is\nworth noting here.\n\n> diff --git a/Documentation/git-format-patch.adoc b/Documentation/git-format-patch.adoc\n> index 9a7807ca71..05c4192dbc 100644\n> --- a/Documentation/git-format-patch.adoc\n> +++ b/Documentation/git-format-patch.adoc\n> @@ -282,11 +282,11 @@ e.g., `--rfc='-(WIP)'` results in \"PATCH (WIP)\".\n>  \n>  --from::\n>  --from=<ident>::\n> -\tUse `ident` in the `From:` header of each commit email. If the\n> -\tauthor ident of the commit is not textually identical to the\n> -\tprovided `ident`, place a `From:` header in the body of the\n> -\tmessage with the original author. If no `ident` is given, use\n> -\tthe committer ident.\n> +\tUse `ident` in the `From:` header of each email. In case of a\n> +\tcommit email, if the author ident of the commit is not textually\n> +\tidentical to the provided `ident`, place a `From:` header in the\n> +\tbody of the message with the original author. If no `ident` is\n> +\tgiven, use the committer ident.\n\nAfter reading the above three times, a natural question that comes\nto mind is what ident is used when this option is not given at all\n(i.e., \"When this option is not given, the committer identity of the\ncurrent user is used for all messages\").\n\n> diff --git a/builtin/log.c b/builtin/log.c\n> index d43ca693bf..42648dda54 100644\n> --- a/builtin/log.c\n> +++ b/builtin/log.c\n\nThe code changes all look good.\n\n> diff --git a/t/t4014-format-patch.sh b/t/t4014-format-patch.sh\n> index 21d6d0cd9e..2135b65cee 100755\n> --- a/t/t4014-format-patch.sh\n> +++ b/t/t4014-format-patch.sh\n> @@ -1472,6 +1472,14 @@ test_expect_success '--from uses committer ident' '\n>  \ttest_cmp expect patch.head\n>  '\n>  \n> +test_expect_success '--from applies to cover letter' '\n> +\ttest_when_finished \"rm -rf patches\" &&\n> +\tgit format-patch -1 --cover-letter --from=\"Foo Bar <author@example.com>\" -o patches &&\n> +\techo \"From: Foo Bar <author@example.com>\" >expect &&\n> +\tgrep \"^From:\" patches/0000-cover-letter.patch >patch.head &&\n> +\ttest_cmp expect patch.head\n> +'\n\nOK.\n\nWe know what filename the cover letter gets, so it is really the\nmatter of how we want to verify the output.  We know that a line\nthat matches \"^From:\" must appear once and only once in the cover\nletter output, so finding that line and comparing it with what we\nexpect to see is a reasonably way to do this.  Good.\n\nThanks.\n\n"},{"id":"536234","messageId":"xmqq342z9eje.fsf@gitster.g","threadId":"64996","inReplyTo":"aZTnmXcLm1MNcIxO@exploit","subject":"Re: [PATCH] format-patch: fix From header in cover letter","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2026-02-17T22:43:49Z","receivedAt":"2026-02-17T22:43:51Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Mirko Faina <mroik@delayed.space> writes:\n\n> I'm sorry, I forgot to mark as v3 and to change the sender name.\n\nHeh, the sender name (as long as it is clear who the messages is from)\ndoes not really matter very much.  Thanks for working on this.\n"},{"id":"536235","messageId":"20260217232519.24898-1-mroik@delayed.space","threadId":"64996","inReplyTo":"20260217220515.14127-1-mroik@delayed.space","subject":"[PATCH v4] format-patch: fix From header in cover letter","fromName":"Mirko Faina","fromEmail":"mroik@delayed.space","sentAt":"2026-02-17T23:25:18Z","receivedAt":"2026-02-17T23:25:45Z","isPatch":true,"sender":{"key":"mroik@delayed.space","avatar":"https://avatars.githubusercontent.com/u/25752903?v=4"},"body":"\"git format-patch\" takes \"--from=<user ident>\" command line option and\nuses the given ident for patch e-mails, but this is not applied to the\ncover letter, the option is ignored and the committer ident of the\ncurrent user is used. This has been the case ever since \"--from\" has\nbeen introduced as it has never been used in make_cover_letter().\n\nTeach the make_cover_letter() function to honor the option, instead of\nalways using the current committer identity. Change variable name from\n\"committer\" to \"from\" to better reflect the purpose of the variable.\n\nSigned-off-by: Mirko Faina <mroik@delayed.space>\n---\n Documentation/git-format-patch.adoc | 11 ++++++-----\n builtin/log.c                       |  6 +++---\n t/t4014-format-patch.sh             |  8 ++++++++\n 3 files changed, 17 insertions(+), 8 deletions(-)\n\ndiff --git a/Documentation/git-format-patch.adoc b/Documentation/git-format-patch.adoc\nindex 9a7807ca71..6ac453958c 100644\n--- a/Documentation/git-format-patch.adoc\n+++ b/Documentation/git-format-patch.adoc\n@@ -282,11 +282,12 @@ e.g., `--rfc='-(WIP)'` results in \"PATCH (WIP)\".\n \n --from::\n --from=<ident>::\n-\tUse `ident` in the `From:` header of each commit email. If the\n-\tauthor ident of the commit is not textually identical to the\n-\tprovided `ident`, place a `From:` header in the body of the\n-\tmessage with the original author. If no `ident` is given, use\n-\tthe committer ident.\n+\tUse `ident` in the `From:` header of each email. In case of a\n+\tcommit email, if the author ident of the commit is not textually\n+\tidentical to the provided `ident`, place a `From:` header in the\n+\tbody of the message with the original author. If no `ident` is\n+\tgiven, or if the option is not passed at all, use the ident of\n+\tthe current committer.\n +\n Note that this option is only useful if you are actually sending the\n emails and want to identify yourself as the sender, but retain the\ndiff --git a/builtin/log.c b/builtin/log.c\nindex d43ca693bf..42648dda54 100644\n--- a/builtin/log.c\n+++ b/builtin/log.c\n@@ -1332,7 +1332,7 @@ static void make_cover_letter(struct rev_info *rev, int use_separate_file,\n \t\t\t      int quiet,\n \t\t\t      const struct format_config *cfg)\n {\n-\tconst char *committer;\n+\tconst char *from;\n \tstruct shortlog log;\n \tstruct strbuf sb = STRBUF_INIT;\n \tint i;\n@@ -1345,7 +1345,7 @@ static void make_cover_letter(struct rev_info *rev, int use_separate_file,\n \tif (!cmit_fmt_is_mail(rev->commit_format))\n \t\tdie(_(\"cover letter needs email format\"));\n \n-\tcommitter = git_committer_info(0);\n+\tfrom = cfg->from ? cfg->from : git_committer_info(0);\n \n \tif (use_separate_file &&\n \t    open_next_file(NULL, rev->numbered_files ? NULL : \"cover-letter\", rev, quiet))\n@@ -1368,7 +1368,7 @@ static void make_cover_letter(struct rev_info *rev, int use_separate_file,\n \tpp.date_mode.type = DATE_RFC2822;\n \tpp.rev = rev;\n \tpp.encode_email_headers = rev->encode_email_headers;\n-\tpp_user_info(&pp, NULL, &sb, committer, encoding);\n+\tpp_user_info(&pp, NULL, &sb, from, encoding);\n \tprepare_cover_text(&pp, description_file, branch_name, &sb,\n \t\t\t   encoding, need_8bit_cte, cfg);\n \tfprintf(rev->diffopt.file, \"%s\\n\", sb.buf);\ndiff --git a/t/t4014-format-patch.sh b/t/t4014-format-patch.sh\nindex 21d6d0cd9e..2135b65cee 100755\n--- a/t/t4014-format-patch.sh\n+++ b/t/t4014-format-patch.sh\n@@ -1472,6 +1472,14 @@ test_expect_success '--from uses committer ident' '\n \ttest_cmp expect patch.head\n '\n \n+test_expect_success '--from applies to cover letter' '\n+\ttest_when_finished \"rm -rf patches\" &&\n+\tgit format-patch -1 --cover-letter --from=\"Foo Bar <author@example.com>\" -o patches &&\n+\techo \"From: Foo Bar <author@example.com>\" >expect &&\n+\tgrep \"^From:\" patches/0000-cover-letter.patch >patch.head &&\n+\ttest_cmp expect patch.head\n+'\n+\n test_expect_success '--from omits redundant in-body header' '\n \tgit format-patch -1 --stdout --from=\"A U Thor <author@example.com>\" >patch &&\n \tcat >expect <<-\\EOF &&\n-- \n2.53.0\n\n"},{"id":"536396","messageId":"20260219112918.GB3529@coredump.intra.peff.net","threadId":"64996","inReplyTo":"CALnO6CD6c36ur4cxqNAB=Jy=m6yxVfoSzAAekewQZr2vjjKn2w@mail.gmail.com","subject":"Re: [PATCH v2] format-patch: fix From header in cover letter","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2026-02-19T11:29:18Z","receivedAt":"2026-02-19T11:29:19Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Tue, Feb 17, 2026 at 08:21:32AM -0500, D. Ben Knoble wrote:\n\n> > I think that wording comes from me back in 2013, and I just never gave\n> > any thought to cover-letter generation by format-patch itself. I never\n> > use it (and I probably forgot it even existed, given that most people\n> > would use send-email's cover letter generation, and I do my own thing\n> > with mutt).\n> \n> Funny: the send-email manual's main mention of cover letters apart\n> from setting Cc/To fields is in an example…\n> \n>            $ git format-patch --cover-letter -M origin/master -o outgoing/\n>            $ edit outgoing/0000-*\n>            $ git send-email outgoing/*\n> \n> …using format-patch! (Which is how I generate cover letters, and\n> probably part of why.)\n\nI think I may be showing my clueless-ness about send-email here. I\nthought it had its own cover-letter code, but looking at it briefly, I\nmay just be wrong. I don't see any code, so I guess people generate the\ncover-letter independently with format-patch.\n\nMaybe nobody noticed because most people do not use \"--from=<foo>\" with\na <foo> that does not match the committer ident in the first place. I'm\nnot really sure why you'd want the two to differ. Which makes me wonder\nwhy I added that feature in the first place (as opposed to just \"--from\"\nwith no options).\n\nMysteries of the cosmos, I guess.\n\n-Peff\n"},{"id":"536398","messageId":"20260219114307.GC3529@coredump.intra.peff.net","threadId":"64996","inReplyTo":"xmqqecmje6o6.fsf@gitster.g","subject":"Re: [PATCH v2] format-patch: fix From header in cover letter","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2026-02-19T11:43:07Z","receivedAt":"2026-02-19T11:43:08Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Tue, Feb 17, 2026 at 07:22:33AM -0800, Junio C Hamano wrote:\n\n> > I never\n> > use it (and I probably forgot it even existed, given that most people\n> > would use send-email's cover letter generation, and I do my own thing\n> > with mutt).\n> \n> I use it myself and I really hate the way it lists the patches.  We\n> should have done \"log --oneline --reverse\" instead of \"shortlog\", as\n> it is hard to understand the reference the cover letter message\n> makes to individual patches like \"the first two patches do X\", etc.\n\nAgreed. I have long hated the shortlog version. According to the commit\nhistory of my personal scripts, I've been sending with:\n\n   [1/3]: subject of the first patch\n   [2/3]: the second patch\n   [3/3]: and so on\n\nsince at least 2009, and nobody has complained. ;)\n\nSadly I don't think there is an easy way to do so with \"log --format\",\nas it can't just be a single output placeholder (you have to do the\nwhole traversal to get the \"/3\" part, so the caller needs to know this\nand queue up the output).\n\nI do it locally by piping the format-patch output through something\nlike:\n\n  sed -ne 's/^Subject: //p' |\n  sed -e 's/\\[PATCH /[/' \\\n      -e 's/]/]:/' \\\n      -e 's/^/  /'\n\nOf course that does not handle rfc822 header continuations, which we\nstarted to do at some point for long subjects. So now the first part is\nsome gnarly perl. :-/\n\nProbably some combination of \"git log --format=%s\", \"nl\", \"wc -l\" would\nbe less horrid. I stuck with format-patch because of its somewhat\nmagical command-line parsing of revisions. E.g., saying \"git\nformat-patch @{upstream}\" will give you the patches on the topic branch,\nrather than all history down to the roots.\n\nBut anyway, if this were happening internally in format-patch's\ncover-letter code, it should be quite easy to do (we have the complete\nlist of patches and their subjects there already).\n\n-Peff\n"},{"id":"536399","messageId":"aZb6Pi_xkDflihHw@exploit","threadId":"64996","inReplyTo":"20260219112918.GB3529@coredump.intra.peff.net","subject":"Re: [PATCH v2] format-patch: fix From header in cover letter","fromName":"Mirko Faina","fromEmail":"mroik@delayed.space","sentAt":"2026-02-19T12:03:45Z","receivedAt":"2026-02-19T12:03:55Z","isPatch":true,"sender":{"key":"mroik@delayed.space","avatar":"https://avatars.githubusercontent.com/u/25752903?v=4"},"body":"> Maybe nobody noticed because most people do not use \"--from=<foo>\" with\n> a <foo> that does not match the committer ident in the first place. I'm\n> not really sure why you'd want the two to differ. Which makes me wonder\n> why I added that feature in the first place (as opposed to just \"--from\"\n> with no options).\n\nI usually commit everything under the name Mroik. Having the \"--from\"\noption is useful to send a one off contribution, otherwise I'd have to\nchange my committer ident everytime I decide to use a different name (I\nknow most people just use their full name so it's not common to have to\nuse \"--from\").\n\nMirko\n"},{"id":"536405","messageId":"CALnO6CAszmGM7uA5zJXaUkK4PMnyQGeWWBk+OwDU=AfDh4GbPA@mail.gmail.com","threadId":"64996","inReplyTo":"20260219112918.GB3529@coredump.intra.peff.net","subject":"Re: [PATCH v2] format-patch: fix From header in cover letter","fromName":"D. Ben Knoble","fromEmail":"ben.knoble@gmail.com","sentAt":"2026-02-19T13:43:42Z","receivedAt":"2026-02-19T13:43:54Z","isPatch":true,"sender":{"key":"ben.knoble@gmail.com","avatar":"https://avatars.githubusercontent.com/u/22802209?v=4"},"body":"On Thu, Feb 19, 2026 at 6:29 AM Jeff King <peff@peff.net> wrote:\n>\n> On Tue, Feb 17, 2026 at 08:21:32AM -0500, D. Ben Knoble wrote:\n>\n> > > I think that wording comes from me back in 2013, and I just never gave\n> > > any thought to cover-letter generation by format-patch itself. I never\n> > > use it (and I probably forgot it even existed, given that most people\n> > > would use send-email's cover letter generation, and I do my own thing\n> > > with mutt).\n> >\n> > Funny: the send-email manual's main mention of cover letters apart\n> > from setting Cc/To fields is in an example…\n> >\n> >            $ git format-patch --cover-letter -M origin/master -o outgoing/\n> >            $ edit outgoing/0000-*\n> >            $ git send-email outgoing/*\n> >\n> > …using format-patch! (Which is how I generate cover letters, and\n> > probably part of why.)\n>\n> I think I may be showing my clueless-ness about send-email here. I\n> thought it had its own cover-letter code, but looking at it briefly, I\n> may just be wrong. I don't see any code, so I guess people generate the\n> cover-letter independently with format-patch.\n\nYeah, maybe—send-email takes format-patch options, so send-email\n--cover--letter should also work?\n\n> Maybe nobody noticed because most people do not use \"--from=<foo>\" with\n> a <foo> that does not match the committer ident in the first place. I'm\n> not really sure why you'd want the two to differ. Which makes me wonder\n> why I added that feature in the first place (as opposed to just \"--from\"\n> with no options).\n>\n> Mysteries of the cosmos, I guess.\n>\n> -Peff\n\n:shrug: :)\n\n-- \nD. Ben Knoble\n"},{"id":"536545","messageId":"xmqqbjhjxp2d.fsf@gitster.g","threadId":"64996","inReplyTo":"20260219114307.GC3529@coredump.intra.peff.net","subject":"Re: [PATCH v2] format-patch: fix From header in cover letter","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2026-02-20T18:11:38Z","receivedAt":"2026-02-20T18:11:41Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jeff King <peff@peff.net> writes:\n\n>> I use it myself and I really hate the way it lists the patches.  We\n>> should have done \"log --oneline --reverse\" instead of \"shortlog\", as\n>> it is hard to understand the reference the cover letter message\n>> makes to individual patches like \"the first two patches do X\", etc.\n>\n> Agreed. I have long hated the shortlog version. According to the commit\n> history of my personal scripts, I've been sending with:\n>\n>    [1/3]: subject of the first patch\n>    [2/3]: the second patch\n>    [3/3]: and so on\n>\n> since at least 2009, and nobody has complained. ;)\n> ...\n> But anyway, if this were happening internally in format-patch's\n> cover-letter code, it should be quite easy to do (we have the complete\n> list of patches and their subjects there already).\n\nA good bite-sized #leftoverbits project for somebody relatively new\nto the codebase, perhaps.\n\nThanks.\n"}]}