* [PATCH] format-patch: fix from header in cover letter
@ 2026-02-14 5:49 Mirko Faina
2026-02-16 11:01 ` Junio C Hamano
2026-02-16 15:27 ` [PATCH v2] format-patch: fix From " Mirko Faina
0 siblings, 2 replies; 19+ messages in thread
From: Mirko Faina @ 2026-02-14 5:49 UTC (permalink / raw)
To: git; +Cc: Junio C Hamano, Mirko Faina
From: Mroik <mroik@delayed.space>
Fixes "From" header for the cover letter when `--from` is passed
Signed-off-by: Mroik <mroik@delayed.space>
---
builtin/log.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/builtin/log.c b/builtin/log.c
index d43ca693bf..df41b43fce 100644
--- a/builtin/log.c
+++ b/builtin/log.c
@@ -1345,7 +1345,7 @@ static void make_cover_letter(struct rev_info *rev, int use_separate_file,
if (!cmit_fmt_is_mail(rev->commit_format))
die(_("cover letter needs email format"));
- committer = git_committer_info(0);
+ committer = cfg->from ? cfg->from : git_committer_info(0);
if (use_separate_file &&
open_next_file(NULL, rev->numbered_files ? NULL : "cover-letter", rev, quiet))
--
2.53.0
^ permalink raw reply related [flat|nested] 19+ messages in thread
* Re: [PATCH] format-patch: fix from header in cover letter
2026-02-14 5:49 [PATCH] format-patch: fix from header in cover letter Mirko Faina
@ 2026-02-16 11:01 ` Junio C Hamano
2026-02-16 15:27 ` [PATCH v2] format-patch: fix From " Mirko Faina
1 sibling, 0 replies; 19+ messages in thread
From: Junio C Hamano @ 2026-02-16 11:01 UTC (permalink / raw)
To: Mirko Faina; +Cc: git
Mirko Faina <mroik@delayed.space> writes:
> Subject: Re: [PATCH] format-patch: fix from header in cover letter
Thanks. That reads well.
> From: Mroik <mroik@delayed.space>
The ident used here matches what is used on the signed-off-by line,
which is good. We tend to prefer people to use their real names,
though (and I suspect that your name probably has some multi-word
structure, not a single-word).
> Fixes "From" header for the cover letter when `--from` is passed
The usual way to compose a log message of this project is to
- Give an observation on how the current system works in the
present tense (so no need to say "Currently X is Y", or
"Previously X was Y" to describe the state before your change;
just "X is Y" is enough), and discuss what you perceive as a
problem in it.
- Propose a solution (optional---often, problem description
trivially leads to an obvious solution in reader's minds).
- Give commands to somebody editing the codebase to "make it so",
instead of saying "This commit does X".
in this order. I am guessing that the problem you are fixing, which
is not said explicitly in what you wrote, is that even when you run
"git format-patch --from='Me <me@my.address>'", the option is not
used for cover letter? If that is the case, perhaps I'd write
something along this line:
"git format-patch" takes "--from=<user ident>" command line
option, and the given ident is used for patch e-mails, but for
the cover letter e-mail, the option is ignored and the committer
ident of the current user is used.
Teach the make_cover_letter() function to honor the option,
instead of always using the current committer identity.
if I were making this change.
> Signed-off-by: Mroik <mroik@delayed.space>
Again, the ident used here matches what is used on the in-body From:
line, which is good.
> ---
> builtin/log.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
This can be tested easily without flakes, so we should add some test
in one of the t/t*-format-patch*.sh files to help people notice when
they breaks this fix by mistake in the future.
> diff --git a/builtin/log.c b/builtin/log.c
> index d43ca693bf..df41b43fce 100644
> --- a/builtin/log.c
> +++ b/builtin/log.c
> @@ -1345,7 +1345,7 @@ static void make_cover_letter(struct rev_info *rev, int use_separate_file,
> if (!cmit_fmt_is_mail(rev->commit_format))
> die(_("cover letter needs email format"));
>
> - committer = git_committer_info(0);
> + committer = cfg->from ? cfg->from : git_committer_info(0);
This is a correct and minimal change, but if I were making this
change, I'd probably rename the "committer" variable. Before the
"--from" option came into play, the function has always assumed that
it should make the cover letter message from the current user, using
their committer ident, which meant that the "From:" address and the
committer ident were synonymous from this function's point of view.
But now we are telling the function that its assumption is no longer
good, and teaching it to honor the "From:" address given in the cfg.
And the way this local variable is used is to point at a string that
is the ident used for the "From:" address, which is not necessarily
the same as committer ident in this new world order. So it is not
reader-friendly to keep using "committer" as the name of the
variable. Simply call it "from", perhaps?
> if (use_separate_file &&
> open_next_file(NULL, rev->numbered_files ? NULL : "cover-letter", rev, quiet))
Thanks.
^ permalink raw reply [flat|nested] 19+ messages in thread
* [PATCH v2] format-patch: fix From header in cover letter
2026-02-14 5:49 [PATCH] format-patch: fix from header in cover letter Mirko Faina
2026-02-16 11:01 ` Junio C Hamano
@ 2026-02-16 15:27 ` Mirko Faina
2026-02-17 6:22 ` Patrick Steinhardt
2026-02-17 22:04 ` [PATCH] " Mroik
1 sibling, 2 replies; 19+ messages in thread
From: Mirko Faina @ 2026-02-16 15:27 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git, Mirko Faina
"git format-patch" takes "--from=<user ident>" command line option and
uses the given ident for patch e-mails, but this is not applied to the
cover letter, the option is ignored and the committer ident of the
current user is used.
Teach the make_cover_letter() function to honor the option, instead of
always using the current committer identity.
Signed-off-by: Mirko Faina <mroik@delayed.space>
---
I'm sorry about the poor quality of the previous commit message, I
realise it did a poor job at explaining what the patch did.
I've applied the changes you suggested and wrote the test.
Thank you for the review.
builtin/log.c | 6 +++---
t/t4014-format-patch.sh | 12 ++++++++++++
2 files changed, 15 insertions(+), 3 deletions(-)
diff --git a/builtin/log.c b/builtin/log.c
index d43ca693bf..42648dda54 100644
--- a/builtin/log.c
+++ b/builtin/log.c
@@ -1332,7 +1332,7 @@ static void make_cover_letter(struct rev_info *rev, int use_separate_file,
int quiet,
const struct format_config *cfg)
{
- const char *committer;
+ const char *from;
struct shortlog log;
struct strbuf sb = STRBUF_INIT;
int i;
@@ -1345,7 +1345,7 @@ static void make_cover_letter(struct rev_info *rev, int use_separate_file,
if (!cmit_fmt_is_mail(rev->commit_format))
die(_("cover letter needs email format"));
- committer = git_committer_info(0);
+ from = cfg->from ? cfg->from : git_committer_info(0);
if (use_separate_file &&
open_next_file(NULL, rev->numbered_files ? NULL : "cover-letter", rev, quiet))
@@ -1368,7 +1368,7 @@ static void make_cover_letter(struct rev_info *rev, int use_separate_file,
pp.date_mode.type = DATE_RFC2822;
pp.rev = rev;
pp.encode_email_headers = rev->encode_email_headers;
- pp_user_info(&pp, NULL, &sb, committer, encoding);
+ pp_user_info(&pp, NULL, &sb, from, encoding);
prepare_cover_text(&pp, description_file, branch_name, &sb,
encoding, need_8bit_cte, cfg);
fprintf(rev->diffopt.file, "%s\n", sb.buf);
diff --git a/t/t4014-format-patch.sh b/t/t4014-format-patch.sh
index 21d6d0cd9e..cb04a9c47b 100755
--- a/t/t4014-format-patch.sh
+++ b/t/t4014-format-patch.sh
@@ -1472,6 +1472,18 @@ test_expect_success '--from uses committer ident' '
test_cmp expect patch.head
'
+test_expect_success '--from applies to cover letter' '
+ echo "This is a test text" >file_to_commit &&
+ git format-patch -1 --stdout --cover-letter --from="Foo Bar <author@example.com>" >patch &&
+ cat >expect <<-\EOF &&
+ From: Foo Bar <author@example.com>
+ From: Foo Bar <author@example.com>
+ From: A U Thor <author@example.com>
+ EOF
+ sed -ne "/^From:/p; /^[[:space:]]$/d" patch >patch.head &&
+ test_cmp expect patch.head
+'
+
test_expect_success '--from omits redundant in-body header' '
git format-patch -1 --stdout --from="A U Thor <author@example.com>" >patch &&
cat >expect <<-\EOF &&
--
2.53.0
^ permalink raw reply related [flat|nested] 19+ messages in thread
* Re: [PATCH v2] format-patch: fix From header in cover letter
2026-02-16 15:27 ` [PATCH v2] format-patch: fix From " Mirko Faina
@ 2026-02-17 6:22 ` Patrick Steinhardt
2026-02-17 6:34 ` Jeff King
2026-02-17 22:04 ` [PATCH] " Mroik
1 sibling, 1 reply; 19+ messages in thread
From: Patrick Steinhardt @ 2026-02-17 6:22 UTC (permalink / raw)
To: Mirko Faina; +Cc: Junio C Hamano, git
On Mon, Feb 16, 2026 at 04:27:30PM +0100, Mirko Faina wrote:
> "git format-patch" takes "--from=<user ident>" command line option and
> uses the given ident for patch e-mails, but this is not applied to the
> cover letter, the option is ignored and the committer ident of the
> current user is used.
I think it makes sense to apply this identity to the cover letter, as
well. After all, I would say that the whole intent is to allow the user
to send those mails from their own mail address, and of course that
would also require us to send the cover letter from that address.
One thing that made me stop though is the folowing sentence in
git-format-patch(1):
Use ident in the From: header of each commit email.
The option explicitly mentions that we use "--from" for the commit
emails, only, and that may be read as implying that it's not used for
the cover letter.
I don't really know whether that wording is intentional, and I cannot
come up with a good reason why it should be. But I'd say that the
wording is something we should adjust.
> diff --git a/builtin/log.c b/builtin/log.c
> index d43ca693bf..42648dda54 100644
> --- a/builtin/log.c
> +++ b/builtin/log.c
> @@ -1332,7 +1332,7 @@ static void make_cover_letter(struct rev_info *rev, int use_separate_file,
> int quiet,
> const struct format_config *cfg)
> {
> - const char *committer;
> + const char *from;
> struct shortlog log;
> struct strbuf sb = STRBUF_INIT;
> int i;
> @@ -1345,7 +1345,7 @@ static void make_cover_letter(struct rev_info *rev, int use_separate_file,
> if (!cmit_fmt_is_mail(rev->commit_format))
> die(_("cover letter needs email format"));
>
> - committer = git_committer_info(0);
> + from = cfg->from ? cfg->from : git_committer_info(0);
>
> if (use_separate_file &&
> open_next_file(NULL, rev->numbered_files ? NULL : "cover-letter", rev, quiet))
> @@ -1368,7 +1368,7 @@ static void make_cover_letter(struct rev_info *rev, int use_separate_file,
> pp.date_mode.type = DATE_RFC2822;
> pp.rev = rev;
> pp.encode_email_headers = rev->encode_email_headers;
> - pp_user_info(&pp, NULL, &sb, committer, encoding);
> + pp_user_info(&pp, NULL, &sb, from, encoding);
> prepare_cover_text(&pp, description_file, branch_name, &sb,
> encoding, need_8bit_cte, cfg);
> fprintf(rev->diffopt.file, "%s\n", sb.buf);
The changes here look straight forward.
> diff --git a/t/t4014-format-patch.sh b/t/t4014-format-patch.sh
> index 21d6d0cd9e..cb04a9c47b 100755
> --- a/t/t4014-format-patch.sh
> +++ b/t/t4014-format-patch.sh
> @@ -1472,6 +1472,18 @@ test_expect_success '--from uses committer ident' '
> test_cmp expect patch.head
> '
>
> +test_expect_success '--from applies to cover letter' '
> + echo "This is a test text" >file_to_commit &&
This file isn't used.
> + git format-patch -1 --stdout --cover-letter --from="Foo Bar <author@example.com>" >patch &&
> + cat >expect <<-\EOF &&
> + From: Foo Bar <author@example.com>
> + From: Foo Bar <author@example.com>
> + From: A U Thor <author@example.com>
> + EOF
> + sed -ne "/^From:/p; /^[[:space:]]$/d" patch >patch.head &&
> + test_cmp expect patch.head
> +'
We're not only testing the cover letter here though, but also the other
generated patch. This makes it somewhat hard to verify that the test
actually works as expected. Would it make sense to maybe use something
like the following instead?
test_expect_success '--from applies to cover letter' '
test_when_finished "rm -rf patches" &&
git format-patch -1 --cover-letter --from="Foo Bar <author@example.com>" -o patches &&
echo "From: Foo Bar <author@example.com>" >expect &&
grep "^From:" patches/0000-cover-letter.patch >patch.head &&
test_cmp expect patch.head
'
Thanks!
Patrick
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH v2] format-patch: fix From header in cover letter
2026-02-17 6:22 ` Patrick Steinhardt
@ 2026-02-17 6:34 ` Jeff King
2026-02-17 13:21 ` D. Ben Knoble
2026-02-17 15:22 ` Junio C Hamano
0 siblings, 2 replies; 19+ messages in thread
From: Jeff King @ 2026-02-17 6:34 UTC (permalink / raw)
To: Patrick Steinhardt; +Cc: Mirko Faina, Junio C Hamano, git
On Tue, Feb 17, 2026 at 07:22:08AM +0100, Patrick Steinhardt wrote:
> One thing that made me stop though is the folowing sentence in
> git-format-patch(1):
>
> Use ident in the From: header of each commit email.
>
> The option explicitly mentions that we use "--from" for the commit
> emails, only, and that may be read as implying that it's not used for
> the cover letter.
>
> I don't really know whether that wording is intentional, and I cannot
> come up with a good reason why it should be. But I'd say that the
> wording is something we should adjust.
I think that wording comes from me back in 2013, and I just never gave
any thought to cover-letter generation by format-patch itself. I never
use it (and I probably forgot it even existed, given that most people
would use send-email's cover letter generation, and I do my own thing
with mutt).
So I think the direction of the patch is good, and I agree it would make
sense to clarify the documentation.
-Peff
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH v2] format-patch: fix From header in cover letter
2026-02-17 6:34 ` Jeff King
@ 2026-02-17 13:21 ` D. Ben Knoble
2026-02-19 11:29 ` Jeff King
2026-02-17 15:22 ` Junio C Hamano
1 sibling, 1 reply; 19+ messages in thread
From: D. Ben Knoble @ 2026-02-17 13:21 UTC (permalink / raw)
To: Jeff King; +Cc: Patrick Steinhardt, Mirko Faina, Junio C Hamano, git
On Tue, Feb 17, 2026 at 1:34 AM Jeff King <peff@peff.net> wrote:
>
> On Tue, Feb 17, 2026 at 07:22:08AM +0100, Patrick Steinhardt wrote:
>
> > One thing that made me stop though is the folowing sentence in
> > git-format-patch(1):
> >
> > Use ident in the From: header of each commit email.
> >
> > The option explicitly mentions that we use "--from" for the commit
> > emails, only, and that may be read as implying that it's not used for
> > the cover letter.
> >
> > I don't really know whether that wording is intentional, and I cannot
> > come up with a good reason why it should be. But I'd say that the
> > wording is something we should adjust.
>
> I think that wording comes from me back in 2013, and I just never gave
> any thought to cover-letter generation by format-patch itself. I never
> use it (and I probably forgot it even existed, given that most people
> would use send-email's cover letter generation, and I do my own thing
> with mutt).
Funny: the send-email manual's main mention of cover letters apart
from setting Cc/To fields is in an example…
$ git format-patch --cover-letter -M origin/master -o outgoing/
$ edit outgoing/0000-*
$ git send-email outgoing/*
…using format-patch! (Which is how I generate cover letters, and
probably part of why.)
--
D. Ben Knoble
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH v2] format-patch: fix From header in cover letter
2026-02-17 6:34 ` Jeff King
2026-02-17 13:21 ` D. Ben Knoble
@ 2026-02-17 15:22 ` Junio C Hamano
2026-02-19 11:43 ` Jeff King
1 sibling, 1 reply; 19+ messages in thread
From: Junio C Hamano @ 2026-02-17 15:22 UTC (permalink / raw)
To: Jeff King; +Cc: Patrick Steinhardt, Mirko Faina, git
Jeff King <peff@peff.net> writes:
> I think that wording comes from me back in 2013, and I just never gave
> any thought to cover-letter generation by format-patch itself.
Figures. If "--from" was done by somebody who did not know or care
about the cover letter, it is totally understandable omission the
patch addresses. The log message may want to refer to a9080475
(teach format-patch to place other authors into in-body "From",
2013-07-03).
> I never
> use it (and I probably forgot it even existed, given that most people
> would use send-email's cover letter generation, and I do my own thing
> with mutt).
I use it myself and I really hate the way it lists the patches. We
should have done "log --oneline --reverse" instead of "shortlog", as
it is hard to understand the reference the cover letter message
makes to individual patches like "the first two patches do X", etc.
> So I think the direction of the patch is good, and I agree it would make
> sense to clarify the documentation.
Yes. It does make sense to document the change in thinking in the
proposed log message and in documentation.
Thanks.
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH v2] format-patch: fix From header in cover letter
@ 2026-02-17 21:30 Mirko Faina
0 siblings, 0 replies; 19+ messages in thread
From: Mirko Faina @ 2026-02-17 21:30 UTC (permalink / raw)
To: Patrick Steinhardt; +Cc: Junio C Hamano, git
On Tue, Feb 17, 2026 at 07:22:08AM +0100, Patrick Steinhardt wrote:
> One thing that made me stop though is the folowing sentence in
> git-format-patch(1):
>
> Use ident in the From: header of each commit email.
>
> The option explicitly mentions that we use "--from" for the commit
> emails, only, and that may be read as implying that it's not used for
> the cover letter.
>
> I don't really know whether that wording is intentional, and I cannot
> come up with a good reason why it should be. But I'd say that the
> wording is something we should adjust.
I don't think any user would reasonably think that it wouldn't apply to
the cover letter as you're sending the whole patch series in bulk, as the
same person.
I will change the documentation to remove any ambiguity.
> We're not only testing the cover letter here though, but also the other
> generated patch. This makes it somewhat hard to verify that the test
> actually works as expected. Would it make sense to maybe use something
> like the following instead?
>
> test_expect_success '--from applies to cover letter' '
> test_when_finished "rm -rf patches" &&
> git format-patch -1 --cover-letter --from="Foo Bar <author@example.com>" -o patches &&
> echo "From: Foo Bar <author@example.com>" >expect &&
> grep "^From:" patches/0000-cover-letter.patch >patch.head &&
> test_cmp expect patch.head
> '
Yes, makes sense, wouldn't want to generate a false negative on the
compliance of the "--from" option.
I will apply the suggested change.
Thank you
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH v2] format-patch: fix From header in cover letter
@ 2026-02-17 21:41 Mirko Faina
0 siblings, 0 replies; 19+ messages in thread
From: Mirko Faina @ 2026-02-17 21:41 UTC (permalink / raw)
To: Junio C Hamano; +Cc: Jeff King, Patrick Steinhardt, git
On Tue, Feb 17, 2026 at 07:22:33AM -0800, Junio C Hamano wrote:
> Yes. It does make sense to document the change in thinking in the
> proposed log message and in documentation.
As I said to Patrick, I don't think anyone would reasonably expect
"--from" to not apply to the cover letter as well. Given this, I'm not
sure we should refer to this as a change in thinking in the commit
message, it should be treated as a bug as if it should've always been
this way.
I will edit the documentation to remove any ambiguity.
Thank you
^ permalink raw reply [flat|nested] 19+ messages in thread
* [PATCH] format-patch: fix From header in cover letter
2026-02-16 15:27 ` [PATCH v2] format-patch: fix From " Mirko Faina
2026-02-17 6:22 ` Patrick Steinhardt
@ 2026-02-17 22:04 ` Mroik
2026-02-17 22:13 ` Mirko Faina
` (2 more replies)
1 sibling, 3 replies; 19+ messages in thread
From: Mroik @ 2026-02-17 22:04 UTC (permalink / raw)
To: git
Cc: Mirko Faina, Junio C Hamano, Patrick Steinhardt, Jeff King,
D . Ben Knoble
From: Mirko Faina <mroik@delayed.space>
"git format-patch" takes "--from=<user ident>" command line option and
uses the given ident for patch e-mails, but this is not applied to the
cover letter, the option is ignored and the committer ident of the
current user is used.
Teach the make_cover_letter() function to honor the option, instead of
always using the current committer identity.
Signed-off-by: Mirko Faina <mroik@delayed.space>
---
Documentation/git-format-patch.adoc | 10 +++++-----
builtin/log.c | 6 +++---
t/t4014-format-patch.sh | 8 ++++++++
3 files changed, 16 insertions(+), 8 deletions(-)
diff --git a/Documentation/git-format-patch.adoc b/Documentation/git-format-patch.adoc
index 9a7807ca71..05c4192dbc 100644
--- a/Documentation/git-format-patch.adoc
+++ b/Documentation/git-format-patch.adoc
@@ -282,11 +282,11 @@ e.g., `--rfc='-(WIP)'` results in "PATCH (WIP)".
--from::
--from=<ident>::
- Use `ident` in the `From:` header of each commit email. If the
- author ident of the commit is not textually identical to the
- provided `ident`, place a `From:` header in the body of the
- message with the original author. If no `ident` is given, use
- the committer ident.
+ Use `ident` in the `From:` header of each email. In case of a
+ commit email, if the author ident of the commit is not textually
+ identical to the provided `ident`, place a `From:` header in the
+ body of the message with the original author. If no `ident` is
+ given, use the committer ident.
+
Note that this option is only useful if you are actually sending the
emails and want to identify yourself as the sender, but retain the
diff --git a/builtin/log.c b/builtin/log.c
index d43ca693bf..42648dda54 100644
--- a/builtin/log.c
+++ b/builtin/log.c
@@ -1332,7 +1332,7 @@ static void make_cover_letter(struct rev_info *rev, int use_separate_file,
int quiet,
const struct format_config *cfg)
{
- const char *committer;
+ const char *from;
struct shortlog log;
struct strbuf sb = STRBUF_INIT;
int i;
@@ -1345,7 +1345,7 @@ static void make_cover_letter(struct rev_info *rev, int use_separate_file,
if (!cmit_fmt_is_mail(rev->commit_format))
die(_("cover letter needs email format"));
- committer = git_committer_info(0);
+ from = cfg->from ? cfg->from : git_committer_info(0);
if (use_separate_file &&
open_next_file(NULL, rev->numbered_files ? NULL : "cover-letter", rev, quiet))
@@ -1368,7 +1368,7 @@ static void make_cover_letter(struct rev_info *rev, int use_separate_file,
pp.date_mode.type = DATE_RFC2822;
pp.rev = rev;
pp.encode_email_headers = rev->encode_email_headers;
- pp_user_info(&pp, NULL, &sb, committer, encoding);
+ pp_user_info(&pp, NULL, &sb, from, encoding);
prepare_cover_text(&pp, description_file, branch_name, &sb,
encoding, need_8bit_cte, cfg);
fprintf(rev->diffopt.file, "%s\n", sb.buf);
diff --git a/t/t4014-format-patch.sh b/t/t4014-format-patch.sh
index 21d6d0cd9e..2135b65cee 100755
--- a/t/t4014-format-patch.sh
+++ b/t/t4014-format-patch.sh
@@ -1472,6 +1472,14 @@ test_expect_success '--from uses committer ident' '
test_cmp expect patch.head
'
+test_expect_success '--from applies to cover letter' '
+ test_when_finished "rm -rf patches" &&
+ git format-patch -1 --cover-letter --from="Foo Bar <author@example.com>" -o patches &&
+ echo "From: Foo Bar <author@example.com>" >expect &&
+ grep "^From:" patches/0000-cover-letter.patch >patch.head &&
+ test_cmp expect patch.head
+'
+
test_expect_success '--from omits redundant in-body header' '
git format-patch -1 --stdout --from="A U Thor <author@example.com>" >patch &&
cat >expect <<-\EOF &&
--
2.53.0
^ permalink raw reply related [flat|nested] 19+ messages in thread
* Re: [PATCH] format-patch: fix From header in cover letter
2026-02-17 22:04 ` [PATCH] " Mroik
@ 2026-02-17 22:13 ` Mirko Faina
2026-02-17 22:43 ` Junio C Hamano
2026-02-17 22:41 ` Junio C Hamano
2026-02-17 23:25 ` [PATCH v4] " Mirko Faina
2 siblings, 1 reply; 19+ messages in thread
From: Mirko Faina @ 2026-02-17 22:13 UTC (permalink / raw)
To: git; +Cc: Junio C Hamano, Patrick Steinhardt, Jeff King, D . Ben Knoble
I'm sorry, I forgot to mark as v3 and to change the sender name.
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH] format-patch: fix From header in cover letter
2026-02-17 22:04 ` [PATCH] " Mroik
2026-02-17 22:13 ` Mirko Faina
@ 2026-02-17 22:41 ` Junio C Hamano
2026-02-17 23:25 ` [PATCH v4] " Mirko Faina
2 siblings, 0 replies; 19+ messages in thread
From: Junio C Hamano @ 2026-02-17 22:41 UTC (permalink / raw)
To: Mroik; +Cc: git, Patrick Steinhardt, Jeff King, D . Ben Knoble
Mroik <mroik@delayed.space> writes:
> From: Mirko Faina <mroik@delayed.space>
>
> "git format-patch" takes "--from=<user ident>" command line option and
> uses the given ident for patch e-mails, but this is not applied to the
> cover letter, the option is ignored and the committer ident of the
> current user is used.
It is worth noting that ever since this "--from" option was
introduced, it was not used when generating the cover letter in the
proposed log message in the above paragraph somewhere.
> Teach the make_cover_letter() function to honor the option, instead of
> always using the current committer identity.
Also the reasoning behind the rename of "committer" to "from" is
worth noting here.
> diff --git a/Documentation/git-format-patch.adoc b/Documentation/git-format-patch.adoc
> index 9a7807ca71..05c4192dbc 100644
> --- a/Documentation/git-format-patch.adoc
> +++ b/Documentation/git-format-patch.adoc
> @@ -282,11 +282,11 @@ e.g., `--rfc='-(WIP)'` results in "PATCH (WIP)".
>
> --from::
> --from=<ident>::
> - Use `ident` in the `From:` header of each commit email. If the
> - author ident of the commit is not textually identical to the
> - provided `ident`, place a `From:` header in the body of the
> - message with the original author. If no `ident` is given, use
> - the committer ident.
> + Use `ident` in the `From:` header of each email. In case of a
> + commit email, if the author ident of the commit is not textually
> + identical to the provided `ident`, place a `From:` header in the
> + body of the message with the original author. If no `ident` is
> + given, use the committer ident.
After reading the above three times, a natural question that comes
to mind is what ident is used when this option is not given at all
(i.e., "When this option is not given, the committer identity of the
current user is used for all messages").
> diff --git a/builtin/log.c b/builtin/log.c
> index d43ca693bf..42648dda54 100644
> --- a/builtin/log.c
> +++ b/builtin/log.c
The code changes all look good.
> diff --git a/t/t4014-format-patch.sh b/t/t4014-format-patch.sh
> index 21d6d0cd9e..2135b65cee 100755
> --- a/t/t4014-format-patch.sh
> +++ b/t/t4014-format-patch.sh
> @@ -1472,6 +1472,14 @@ test_expect_success '--from uses committer ident' '
> test_cmp expect patch.head
> '
>
> +test_expect_success '--from applies to cover letter' '
> + test_when_finished "rm -rf patches" &&
> + git format-patch -1 --cover-letter --from="Foo Bar <author@example.com>" -o patches &&
> + echo "From: Foo Bar <author@example.com>" >expect &&
> + grep "^From:" patches/0000-cover-letter.patch >patch.head &&
> + test_cmp expect patch.head
> +'
OK.
We know what filename the cover letter gets, so it is really the
matter of how we want to verify the output. We know that a line
that matches "^From:" must appear once and only once in the cover
letter output, so finding that line and comparing it with what we
expect to see is a reasonably way to do this. Good.
Thanks.
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH] format-patch: fix From header in cover letter
2026-02-17 22:13 ` Mirko Faina
@ 2026-02-17 22:43 ` Junio C Hamano
0 siblings, 0 replies; 19+ messages in thread
From: Junio C Hamano @ 2026-02-17 22:43 UTC (permalink / raw)
To: Mirko Faina; +Cc: git, Patrick Steinhardt, Jeff King, D . Ben Knoble
Mirko Faina <mroik@delayed.space> writes:
> I'm sorry, I forgot to mark as v3 and to change the sender name.
Heh, the sender name (as long as it is clear who the messages is from)
does not really matter very much. Thanks for working on this.
^ permalink raw reply [flat|nested] 19+ messages in thread
* [PATCH v4] format-patch: fix From header in cover letter
2026-02-17 22:04 ` [PATCH] " Mroik
2026-02-17 22:13 ` Mirko Faina
2026-02-17 22:41 ` Junio C Hamano
@ 2026-02-17 23:25 ` Mirko Faina
2 siblings, 0 replies; 19+ messages in thread
From: Mirko Faina @ 2026-02-17 23:25 UTC (permalink / raw)
To: git
Cc: Mirko Faina, Junio C Hamano, Patrick Steinhardt, Jeff King,
D . Ben Knoble
"git format-patch" takes "--from=<user ident>" command line option and
uses the given ident for patch e-mails, but this is not applied to the
cover letter, the option is ignored and the committer ident of the
current user is used. This has been the case ever since "--from" has
been introduced as it has never been used in make_cover_letter().
Teach the make_cover_letter() function to honor the option, instead of
always using the current committer identity. Change variable name from
"committer" to "from" to better reflect the purpose of the variable.
Signed-off-by: Mirko Faina <mroik@delayed.space>
---
Documentation/git-format-patch.adoc | 11 ++++++-----
builtin/log.c | 6 +++---
t/t4014-format-patch.sh | 8 ++++++++
3 files changed, 17 insertions(+), 8 deletions(-)
diff --git a/Documentation/git-format-patch.adoc b/Documentation/git-format-patch.adoc
index 9a7807ca71..6ac453958c 100644
--- a/Documentation/git-format-patch.adoc
+++ b/Documentation/git-format-patch.adoc
@@ -282,11 +282,12 @@ e.g., `--rfc='-(WIP)'` results in "PATCH (WIP)".
--from::
--from=<ident>::
- Use `ident` in the `From:` header of each commit email. If the
- author ident of the commit is not textually identical to the
- provided `ident`, place a `From:` header in the body of the
- message with the original author. If no `ident` is given, use
- the committer ident.
+ Use `ident` in the `From:` header of each email. In case of a
+ commit email, if the author ident of the commit is not textually
+ identical to the provided `ident`, place a `From:` header in the
+ body of the message with the original author. If no `ident` is
+ given, or if the option is not passed at all, use the ident of
+ the current committer.
+
Note that this option is only useful if you are actually sending the
emails and want to identify yourself as the sender, but retain the
diff --git a/builtin/log.c b/builtin/log.c
index d43ca693bf..42648dda54 100644
--- a/builtin/log.c
+++ b/builtin/log.c
@@ -1332,7 +1332,7 @@ static void make_cover_letter(struct rev_info *rev, int use_separate_file,
int quiet,
const struct format_config *cfg)
{
- const char *committer;
+ const char *from;
struct shortlog log;
struct strbuf sb = STRBUF_INIT;
int i;
@@ -1345,7 +1345,7 @@ static void make_cover_letter(struct rev_info *rev, int use_separate_file,
if (!cmit_fmt_is_mail(rev->commit_format))
die(_("cover letter needs email format"));
- committer = git_committer_info(0);
+ from = cfg->from ? cfg->from : git_committer_info(0);
if (use_separate_file &&
open_next_file(NULL, rev->numbered_files ? NULL : "cover-letter", rev, quiet))
@@ -1368,7 +1368,7 @@ static void make_cover_letter(struct rev_info *rev, int use_separate_file,
pp.date_mode.type = DATE_RFC2822;
pp.rev = rev;
pp.encode_email_headers = rev->encode_email_headers;
- pp_user_info(&pp, NULL, &sb, committer, encoding);
+ pp_user_info(&pp, NULL, &sb, from, encoding);
prepare_cover_text(&pp, description_file, branch_name, &sb,
encoding, need_8bit_cte, cfg);
fprintf(rev->diffopt.file, "%s\n", sb.buf);
diff --git a/t/t4014-format-patch.sh b/t/t4014-format-patch.sh
index 21d6d0cd9e..2135b65cee 100755
--- a/t/t4014-format-patch.sh
+++ b/t/t4014-format-patch.sh
@@ -1472,6 +1472,14 @@ test_expect_success '--from uses committer ident' '
test_cmp expect patch.head
'
+test_expect_success '--from applies to cover letter' '
+ test_when_finished "rm -rf patches" &&
+ git format-patch -1 --cover-letter --from="Foo Bar <author@example.com>" -o patches &&
+ echo "From: Foo Bar <author@example.com>" >expect &&
+ grep "^From:" patches/0000-cover-letter.patch >patch.head &&
+ test_cmp expect patch.head
+'
+
test_expect_success '--from omits redundant in-body header' '
git format-patch -1 --stdout --from="A U Thor <author@example.com>" >patch &&
cat >expect <<-\EOF &&
--
2.53.0
^ permalink raw reply related [flat|nested] 19+ messages in thread
* Re: [PATCH v2] format-patch: fix From header in cover letter
2026-02-17 13:21 ` D. Ben Knoble
@ 2026-02-19 11:29 ` Jeff King
2026-02-19 12:03 ` Mirko Faina
2026-02-19 13:43 ` D. Ben Knoble
0 siblings, 2 replies; 19+ messages in thread
From: Jeff King @ 2026-02-19 11:29 UTC (permalink / raw)
To: D. Ben Knoble; +Cc: Patrick Steinhardt, Mirko Faina, Junio C Hamano, git
On Tue, Feb 17, 2026 at 08:21:32AM -0500, D. Ben Knoble wrote:
> > I think that wording comes from me back in 2013, and I just never gave
> > any thought to cover-letter generation by format-patch itself. I never
> > use it (and I probably forgot it even existed, given that most people
> > would use send-email's cover letter generation, and I do my own thing
> > with mutt).
>
> Funny: the send-email manual's main mention of cover letters apart
> from setting Cc/To fields is in an example…
>
> $ git format-patch --cover-letter -M origin/master -o outgoing/
> $ edit outgoing/0000-*
> $ git send-email outgoing/*
>
> …using format-patch! (Which is how I generate cover letters, and
> probably part of why.)
I think I may be showing my clueless-ness about send-email here. I
thought it had its own cover-letter code, but looking at it briefly, I
may just be wrong. I don't see any code, so I guess people generate the
cover-letter independently with format-patch.
Maybe nobody noticed because most people do not use "--from=<foo>" with
a <foo> that does not match the committer ident in the first place. I'm
not really sure why you'd want the two to differ. Which makes me wonder
why I added that feature in the first place (as opposed to just "--from"
with no options).
Mysteries of the cosmos, I guess.
-Peff
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH v2] format-patch: fix From header in cover letter
2026-02-17 15:22 ` Junio C Hamano
@ 2026-02-19 11:43 ` Jeff King
2026-02-20 18:11 ` Junio C Hamano
0 siblings, 1 reply; 19+ messages in thread
From: Jeff King @ 2026-02-19 11:43 UTC (permalink / raw)
To: Junio C Hamano; +Cc: Patrick Steinhardt, Mirko Faina, git
On Tue, Feb 17, 2026 at 07:22:33AM -0800, Junio C Hamano wrote:
> > I never
> > use it (and I probably forgot it even existed, given that most people
> > would use send-email's cover letter generation, and I do my own thing
> > with mutt).
>
> I use it myself and I really hate the way it lists the patches. We
> should have done "log --oneline --reverse" instead of "shortlog", as
> it is hard to understand the reference the cover letter message
> makes to individual patches like "the first two patches do X", etc.
Agreed. I have long hated the shortlog version. According to the commit
history of my personal scripts, I've been sending with:
[1/3]: subject of the first patch
[2/3]: the second patch
[3/3]: and so on
since at least 2009, and nobody has complained. ;)
Sadly I don't think there is an easy way to do so with "log --format",
as it can't just be a single output placeholder (you have to do the
whole traversal to get the "/3" part, so the caller needs to know this
and queue up the output).
I do it locally by piping the format-patch output through something
like:
sed -ne 's/^Subject: //p' |
sed -e 's/\[PATCH /[/' \
-e 's/]/]:/' \
-e 's/^/ /'
Of course that does not handle rfc822 header continuations, which we
started to do at some point for long subjects. So now the first part is
some gnarly perl. :-/
Probably some combination of "git log --format=%s", "nl", "wc -l" would
be less horrid. I stuck with format-patch because of its somewhat
magical command-line parsing of revisions. E.g., saying "git
format-patch @{upstream}" will give you the patches on the topic branch,
rather than all history down to the roots.
But anyway, if this were happening internally in format-patch's
cover-letter code, it should be quite easy to do (we have the complete
list of patches and their subjects there already).
-Peff
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH v2] format-patch: fix From header in cover letter
2026-02-19 11:29 ` Jeff King
@ 2026-02-19 12:03 ` Mirko Faina
2026-02-19 13:43 ` D. Ben Knoble
1 sibling, 0 replies; 19+ messages in thread
From: Mirko Faina @ 2026-02-19 12:03 UTC (permalink / raw)
To: Jeff King
Cc: D. Ben Knoble, Patrick Steinhardt, Junio C Hamano, git,
Mirko Faina
> Maybe nobody noticed because most people do not use "--from=<foo>" with
> a <foo> that does not match the committer ident in the first place. I'm
> not really sure why you'd want the two to differ. Which makes me wonder
> why I added that feature in the first place (as opposed to just "--from"
> with no options).
I usually commit everything under the name Mroik. Having the "--from"
option is useful to send a one off contribution, otherwise I'd have to
change my committer ident everytime I decide to use a different name (I
know most people just use their full name so it's not common to have to
use "--from").
Mirko
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH v2] format-patch: fix From header in cover letter
2026-02-19 11:29 ` Jeff King
2026-02-19 12:03 ` Mirko Faina
@ 2026-02-19 13:43 ` D. Ben Knoble
1 sibling, 0 replies; 19+ messages in thread
From: D. Ben Knoble @ 2026-02-19 13:43 UTC (permalink / raw)
To: Jeff King; +Cc: Patrick Steinhardt, Mirko Faina, Junio C Hamano, git
On Thu, Feb 19, 2026 at 6:29 AM Jeff King <peff@peff.net> wrote:
>
> On Tue, Feb 17, 2026 at 08:21:32AM -0500, D. Ben Knoble wrote:
>
> > > I think that wording comes from me back in 2013, and I just never gave
> > > any thought to cover-letter generation by format-patch itself. I never
> > > use it (and I probably forgot it even existed, given that most people
> > > would use send-email's cover letter generation, and I do my own thing
> > > with mutt).
> >
> > Funny: the send-email manual's main mention of cover letters apart
> > from setting Cc/To fields is in an example…
> >
> > $ git format-patch --cover-letter -M origin/master -o outgoing/
> > $ edit outgoing/0000-*
> > $ git send-email outgoing/*
> >
> > …using format-patch! (Which is how I generate cover letters, and
> > probably part of why.)
>
> I think I may be showing my clueless-ness about send-email here. I
> thought it had its own cover-letter code, but looking at it briefly, I
> may just be wrong. I don't see any code, so I guess people generate the
> cover-letter independently with format-patch.
Yeah, maybe—send-email takes format-patch options, so send-email
--cover--letter should also work?
> Maybe nobody noticed because most people do not use "--from=<foo>" with
> a <foo> that does not match the committer ident in the first place. I'm
> not really sure why you'd want the two to differ. Which makes me wonder
> why I added that feature in the first place (as opposed to just "--from"
> with no options).
>
> Mysteries of the cosmos, I guess.
>
> -Peff
:shrug: :)
--
D. Ben Knoble
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH v2] format-patch: fix From header in cover letter
2026-02-19 11:43 ` Jeff King
@ 2026-02-20 18:11 ` Junio C Hamano
0 siblings, 0 replies; 19+ messages in thread
From: Junio C Hamano @ 2026-02-20 18:11 UTC (permalink / raw)
To: Jeff King; +Cc: Patrick Steinhardt, Mirko Faina, git
Jeff King <peff@peff.net> writes:
>> I use it myself and I really hate the way it lists the patches. We
>> should have done "log --oneline --reverse" instead of "shortlog", as
>> it is hard to understand the reference the cover letter message
>> makes to individual patches like "the first two patches do X", etc.
>
> Agreed. I have long hated the shortlog version. According to the commit
> history of my personal scripts, I've been sending with:
>
> [1/3]: subject of the first patch
> [2/3]: the second patch
> [3/3]: and so on
>
> since at least 2009, and nobody has complained. ;)
> ...
> But anyway, if this were happening internally in format-patch's
> cover-letter code, it should be quite easy to do (we have the complete
> list of patches and their subjects there already).
A good bite-sized #leftoverbits project for somebody relatively new
to the codebase, perhaps.
Thanks.
^ permalink raw reply [flat|nested] 19+ messages in thread
end of thread, other threads:[~2026-02-20 18:11 UTC | newest]
Thread overview: 19+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-02-14 5:49 [PATCH] format-patch: fix from header in cover letter Mirko Faina
2026-02-16 11:01 ` Junio C Hamano
2026-02-16 15:27 ` [PATCH v2] format-patch: fix From " Mirko Faina
2026-02-17 6:22 ` Patrick Steinhardt
2026-02-17 6:34 ` Jeff King
2026-02-17 13:21 ` D. Ben Knoble
2026-02-19 11:29 ` Jeff King
2026-02-19 12:03 ` Mirko Faina
2026-02-19 13:43 ` D. Ben Knoble
2026-02-17 15:22 ` Junio C Hamano
2026-02-19 11:43 ` Jeff King
2026-02-20 18:11 ` Junio C Hamano
2026-02-17 22:04 ` [PATCH] " Mroik
2026-02-17 22:13 ` Mirko Faina
2026-02-17 22:43 ` Junio C Hamano
2026-02-17 22:41 ` Junio C Hamano
2026-02-17 23:25 ` [PATCH v4] " Mirko Faina
-- strict thread matches above, loose matches on Subject: below --
2026-02-17 21:30 [PATCH v2] " Mirko Faina
2026-02-17 21:41 Mirko Faina
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox