send-email: clarify missing subject error

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>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
main
Harald Nordgren 2026-08-10 17:53:32 +00:00 committed by Junio C Hamano
parent 010afd3166
commit b0b304c10a
2 changed files with 16 additions and 1 deletions

View File

@ -863,7 +863,7 @@ sub get_patch_subject {
return "GIT: $1\n"; return "GIT: $1\n";
} }
close $fh; close $fh;
die sprintf(__("No subject line in %s?"), $fn); die sprintf(__("No 'Subject:' line in '%s'\n"), $fn);
} }


if ($compose) { if ($compose) {

View File

@ -1422,6 +1422,21 @@ test_expect_success $PREREQ 'detects ambiguous reference/file conflict' '
test_grep disambiguate errors 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' ' test_expect_success $PREREQ 'feed two files' '
rm -fr outdir && rm -fr outdir &&
git format-patch -2 -o outdir && git format-patch -2 -o outdir &&