* [PATCH] send-email: clarify missing subject error
@ 2026-08-09 9:23 Harald Nordgren via GitGitGadget
2026-08-09 19:13 ` Junio C Hamano
2026-08-10 17:53 ` [PATCH v2] " Harald Nordgren via GitGitGadget
0 siblings, 2 replies; 6+ messages in thread
From: Harald Nordgren via GitGitGadget @ 2026-08-09 9:23 UTC (permalink / raw)
To: git; +Cc: Harald Nordgren, Harald Nordgren
From: Harald Nordgren <haraldnordgren@gmail.com>
Explain the required Subject: prefix when a message file has no subject.
Terminate the error with a newline so Perl does not append its internal
source location.
Signed-off-by: Harald Nordgren <haraldnordgren@gmail.com>
---
send-email: clarify missing subject error
Explain the required Subject: prefix when a message file has no subject.
Terminate the error with a newline so Perl does not append its internal
source location.
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-2375%2FHaraldNordgren%2Ffix%2Fsend-email-subject-error-v1
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-2375/HaraldNordgren/fix/send-email-subject-error-v1
Pull-Request: https://github.com/git/git/pull/2375
git-send-email.perl | 3 ++-
t/t9001-send-email.sh | 15 +++++++++++++++
2 files changed, 17 insertions(+), 1 deletion(-)
diff --git a/git-send-email.perl b/git-send-email.perl
index bb8ddd1eef..4d76d53c49 100755
--- a/git-send-email.perl
+++ b/git-send-email.perl
@@ -863,7 +863,8 @@ sub get_patch_subject {
return "GIT: $1\n";
}
close $fh;
- die sprintf(__("No subject line in %s?"), $fn);
+ die sprintf(__("No subject line in %s. " .
+ "The first line must start with \"Subject: \"\n"), $fn);
}
if ($compose) {
diff --git a/t/t9001-send-email.sh b/t/t9001-send-email.sh
index e9d814a34a..a403dd278b 100755
--- a/t/t9001-send-email.sh
+++ b/t/t9001-send-email.sh
@@ -1422,6 +1422,21 @@ test_expect_success $PREREQ 'detects ambiguous reference/file conflict' '
test_grep disambiguate errors
'
+test_expect_success $PREREQ 'missing subject omits Perl location' '
+ cat >no-subject.patch <<-\EOF &&
+ This is the body.
+ EOF
+ test_must_fail git send-email \
+ --dry-run \
+ --from="Example <nobody@example.com>" \
+ --to=nobody@example.com \
+ no-subject.patch 2>actual &&
+ cat >expect <<-\EOF &&
+ No subject line in no-subject.patch. The first line must start with "Subject: "
+ EOF
+ test_cmp expect actual
+'
+
test_expect_success $PREREQ 'feed two files' '
rm -fr outdir &&
git format-patch -2 -o outdir &&
base-commit: 010afd3166ddc64c9863b1506f12cbcdda0d4ea1
--
gitgitgadget
^ permalink raw reply related [flat|nested] 6+ messages in thread* Re: [PATCH] send-email: clarify missing subject error
2026-08-09 9:23 [PATCH] send-email: clarify missing subject error Harald Nordgren via GitGitGadget
@ 2026-08-09 19:13 ` Junio C Hamano
2026-08-10 9:48 ` Harald Nordgren
2026-08-10 17:53 ` [PATCH v2] " Harald Nordgren via GitGitGadget
1 sibling, 1 reply; 6+ messages in thread
From: Junio C Hamano @ 2026-08-09 19:13 UTC (permalink / raw)
To: Harald Nordgren via GitGitGadget; +Cc: git, Harald Nordgren
"Harald Nordgren via GitGitGadget" <gitgitgadget@gmail.com> writes:
> From: Harald Nordgren <haraldnordgren@gmail.com>
>
> Explain the required Subject: prefix when a message file has no subject.
Yes, get_patch_subject() is called from places where the caller
wants to determine whether the given file has at least one line that
begins with 'Subject:'. In that case, the subroutine returns the
rest of that line; if it does not find any such line, it issues an
error message and dies.
As a side note, the check is curiously case-sensitive. It is also
curious that the scanning does not stop at the first blank line that
terminates the email headers. However, do not change this behavior
without studying the possible ramifications. People have learned to
use various inputs that are not exactly what is output by 'git
format-patch', so rejecting a 'malformed' file simply because it
differs from typical 'git format-patch' output will break someone's
established workflow.
> Terminate the error with a newline so Perl does not append its internal
> source location.
Very nice spotting. For an end-user facing script, the source
location is not useful. The user is not debugging and fixing the
send-email script after all ;-).
> diff --git a/git-send-email.perl b/git-send-email.perl
> index bb8ddd1eef..4d76d53c49 100755
> --- a/git-send-email.perl
> +++ b/git-send-email.perl
> @@ -863,7 +863,8 @@ sub get_patch_subject {
> return "GIT: $1\n";
> }
> close $fh;
> - die sprintf(__("No subject line in %s?"), $fn);
> + die sprintf(__("No subject line in %s. " .
> + "The first line must start with \"Subject: \"\n"), $fn);
> }
An input file to the 'git send-email' program is often the output
of 'git format-patch'. Such a file begins with a UNIX 'From '
line, followed by email headers such as 'From:', 'Date:', and
'Subject:'. The 'Subject:' line cannot be the first line of
the file in this case, yet it is a valid input.
The only condition that this subroutine flags as an error is when
the file lacks a subject line. "No 'Subject:' line in '%s'\n" is a
clear message to display and is an improvement over the original.
However, the fact that the first line does not start with
"Subject:" is irrelevant to the basis of the subroutine's
decision to issue an error, I think.
Thanks.
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [PATCH] send-email: clarify missing subject error
2026-08-09 19:13 ` Junio C Hamano
@ 2026-08-10 9:48 ` Harald Nordgren
2026-08-10 15:28 ` Junio C Hamano
0 siblings, 1 reply; 6+ messages in thread
From: Harald Nordgren @ 2026-08-10 9:48 UTC (permalink / raw)
To: Junio C Hamano; +Cc: Harald Nordgren via GitGitGadget, git
> An input file to the 'git send-email' program is often the output
> of 'git format-patch'. Such a file begins with a UNIX 'From '
> line, followed by email headers such as 'From:', 'Date:', and
> 'Subject:'. The 'Subject:' line cannot be the first line of
> the file in this case, yet it is a valid input.
>
> The only condition that this subroutine flags as an error is when
> the file lacks a subject line. "No 'Subject:' line in '%s'\n" is a
> clear message to display and is an improvement over the original.
>
> However, the fact that the first line does not start with
> "Subject:" is irrelevant to the basis of the subroutine's
> decision to issue an error, I think.
Yeah, that makes sense, so maybe we don't need to focus on it being
the first line, but Subject needs to be there somewhere before the
body.
Harald
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] send-email: clarify missing subject error
2026-08-10 9:48 ` Harald Nordgren
@ 2026-08-10 15:28 ` Junio C Hamano
0 siblings, 0 replies; 6+ messages in thread
From: Junio C Hamano @ 2026-08-10 15:28 UTC (permalink / raw)
To: Harald Nordgren; +Cc: Harald Nordgren via GitGitGadget, git
Harald Nordgren <haraldnordgren@gmail.com> writes:
>> An input file to the 'git send-email' program is often the output
>> of 'git format-patch'. Such a file begins with a UNIX 'From '
>> line, followed by email headers such as 'From:', 'Date:', and
>> 'Subject:'. The 'Subject:' line cannot be the first line of
>> the file in this case, yet it is a valid input.
>>
>> The only condition that this subroutine flags as an error is when
>> the file lacks a subject line. "No 'Subject:' line in '%s'\n" is a
>> clear message to display and is an improvement over the original.
>>
>> However, the fact that the first line does not start with
>> "Subject:" is irrelevant to the basis of the subroutine's
>> decision to issue an error, I think.
>
> Yeah, that makes sense, so maybe we don't need to focus on it being
> the first line, but Subject needs to be there somewhere before the
> body.
Yeah, the curious thing is that the subroutine with the loop is
happy as long as it finds "^Subject: " somewhere, not necessarily
before the first blank line.
That is why I said "No 'Subject: ' line in '%s'\n" is clear enough
and an improvement over the original. Anything else will add lie to
it.
Thanks.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH v2] send-email: clarify missing subject error
2026-08-09 9:23 [PATCH] send-email: clarify missing subject error Harald Nordgren via GitGitGadget
2026-08-09 19:13 ` Junio C Hamano
@ 2026-08-10 17:53 ` Harald Nordgren via GitGitGadget
2026-08-10 21:09 ` Junio C Hamano
1 sibling, 1 reply; 6+ messages in thread
From: Harald Nordgren via GitGitGadget @ 2026-08-10 17:53 UTC (permalink / raw)
To: git; +Cc: Harald Nordgren, Harald Nordgren
From: Harald Nordgren <haraldnordgren@gmail.com>
Clarify that a message file is missing a 'Subject:' line.
Terminate the error with a newline so Perl does not append its internal
source location.
Signed-off-by: Harald Nordgren <haraldnordgren@gmail.com>
---
send-email: clarify missing subject error
Explain the required Subject: prefix when a message file has no subject.
Terminate the error with a newline so Perl does not append its internal
source location.
Changes in v2:
* Remove the incorrect claim that Subject: must be the first line.
Report the missing header directly as No 'Subject:' line in '<file>'.
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-2375%2FHaraldNordgren%2Ffix%2Fsend-email-subject-error-v2
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-2375/HaraldNordgren/fix/send-email-subject-error-v2
Pull-Request: https://github.com/git/git/pull/2375
Range-diff vs v1:
1: fe4171b0dc ! 1: 7002c5d5f1 send-email: clarify missing subject error
@@ Metadata
## Commit message ##
send-email: clarify missing subject error
- Explain the required Subject: prefix when a message file has no subject.
+ Clarify that a message file is missing a 'Subject:' line.
+
Terminate the error with a newline so Perl does not append its internal
source location.
@@ git-send-email.perl: sub get_patch_subject {
}
close $fh;
- die sprintf(__("No subject line in %s?"), $fn);
-+ die sprintf(__("No subject line in %s. " .
-+ "The first line must start with \"Subject: \"\n"), $fn);
++ die sprintf(__("No 'Subject:' line in '%s'\n"), $fn);
}
if ($compose) {
@@ t/t9001-send-email.sh: test_expect_success $PREREQ 'detects ambiguous reference/
+ --to=nobody@example.com \
+ no-subject.patch 2>actual &&
+ cat >expect <<-\EOF &&
-+ No subject line in no-subject.patch. The first line must start with "Subject: "
++ No '\''Subject:'\'' line in '\''no-subject.patch'\''
+ EOF
+ test_cmp expect actual
+'
git-send-email.perl | 2 +-
t/t9001-send-email.sh | 15 +++++++++++++++
2 files changed, 16 insertions(+), 1 deletion(-)
diff --git a/git-send-email.perl b/git-send-email.perl
index bb8ddd1eef..2071cff6ae 100755
--- a/git-send-email.perl
+++ b/git-send-email.perl
@@ -863,7 +863,7 @@ sub get_patch_subject {
return "GIT: $1\n";
}
close $fh;
- die sprintf(__("No subject line in %s?"), $fn);
+ die sprintf(__("No 'Subject:' line in '%s'\n"), $fn);
}
if ($compose) {
diff --git a/t/t9001-send-email.sh b/t/t9001-send-email.sh
index e9d814a34a..d1393ef197 100755
--- a/t/t9001-send-email.sh
+++ b/t/t9001-send-email.sh
@@ -1422,6 +1422,21 @@ test_expect_success $PREREQ 'detects ambiguous reference/file conflict' '
test_grep disambiguate errors
'
+test_expect_success $PREREQ 'missing subject omits Perl location' '
+ cat >no-subject.patch <<-\EOF &&
+ This is the body.
+ EOF
+ test_must_fail git send-email \
+ --dry-run \
+ --from="Example <nobody@example.com>" \
+ --to=nobody@example.com \
+ no-subject.patch 2>actual &&
+ cat >expect <<-\EOF &&
+ No '\''Subject:'\'' line in '\''no-subject.patch'\''
+ EOF
+ test_cmp expect actual
+'
+
test_expect_success $PREREQ 'feed two files' '
rm -fr outdir &&
git format-patch -2 -o outdir &&
base-commit: 010afd3166ddc64c9863b1506f12cbcdda0d4ea1
--
gitgitgadget
^ permalink raw reply related [flat|nested] 6+ messages in thread* Re: [PATCH v2] send-email: clarify missing subject error
2026-08-10 17:53 ` [PATCH v2] " Harald Nordgren via GitGitGadget
@ 2026-08-10 21:09 ` Junio C Hamano
0 siblings, 0 replies; 6+ messages in thread
From: Junio C Hamano @ 2026-08-10 21:09 UTC (permalink / raw)
To: Harald Nordgren via GitGitGadget; +Cc: git, Harald Nordgren
"Harald Nordgren via GitGitGadget" <gitgitgadget@gmail.com> writes:
> +test_expect_success $PREREQ 'missing subject omits Perl location' '
> + cat >no-subject.patch <<-\EOF &&
> + This is the body.
> + EOF
> + test_must_fail git send-email \
> + --dry-run \
> + --from="Example <nobody@example.com>" \
> + --to=nobody@example.com \
> + no-subject.patch 2>actual &&
> + cat >expect <<-\EOF &&
> + No '\''Subject:'\'' line in '\''no-subject.patch'\''
> + EOF
OK. We require the message to exactly be this one (not starting
with this substring), which makes sure we are not getting the line
numbers from die. Good.
Will queue. This round looks perfect. Let's mark it for 'next'.
Thanks.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2026-08-10 21:09 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-09 9:23 [PATCH] send-email: clarify missing subject error Harald Nordgren via GitGitGadget
2026-08-09 19:13 ` Junio C Hamano
2026-08-10 9:48 ` Harald Nordgren
2026-08-10 15:28 ` Junio C Hamano
2026-08-10 17:53 ` [PATCH v2] " Harald Nordgren via GitGitGadget
2026-08-10 21:09 ` Junio C Hamano
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox