{"thread":{"id":"66144","subject":"[PATCH] send-email: clarify missing subject error","startedAt":"2026-08-09T09:23:17Z","lastAt":"2026-08-10T21:09:30Z","messageCount":6,"participants":["Harald Nordgren via GitGitGadget","Junio C Hamano","Harald Nordgren"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"550118","messageId":"pull.2375.git.git.1786267394375.gitgitgadget@gmail.com","threadId":"66144","inReplyTo":null,"subject":"[PATCH] send-email: clarify missing subject error","fromName":"Harald Nordgren via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2026-08-09T09:23:14Z","receivedAt":"2026-08-09T09:23:17Z","isPatch":true,"body":"From: Harald Nordgren <haraldnordgren@gmail.com>\n\nExplain the required Subject: prefix when a message file has no subject.\nTerminate the error with a newline so Perl does not append its internal\nsource location.\n\nSigned-off-by: Harald Nordgren <haraldnordgren@gmail.com>\n---\n    send-email: clarify missing subject error\n    \n    Explain the required Subject: prefix when a message file has no subject.\n    Terminate the error with a newline so Perl does not append its internal\n    source location.\n\nPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-2375%2FHaraldNordgren%2Ffix%2Fsend-email-subject-error-v1\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-2375/HaraldNordgren/fix/send-email-subject-error-v1\nPull-Request: https://github.com/git/git/pull/2375\n\n git-send-email.perl   |  3 ++-\n t/t9001-send-email.sh | 15 +++++++++++++++\n 2 files changed, 17 insertions(+), 1 deletion(-)\n\ndiff --git a/git-send-email.perl b/git-send-email.perl\nindex bb8ddd1eef..4d76d53c49 100755\n--- a/git-send-email.perl\n+++ b/git-send-email.perl\n@@ -863,7 +863,8 @@ sub get_patch_subject {\n \t\treturn \"GIT: $1\\n\";\n \t}\n \tclose $fh;\n-\tdie sprintf(__(\"No subject line in %s?\"), $fn);\n+\tdie sprintf(__(\"No subject line in %s. \" .\n+\t\t\"The first line must start with \\\"Subject: \\\"\\n\"), $fn);\n }\n \n if ($compose) {\ndiff --git a/t/t9001-send-email.sh b/t/t9001-send-email.sh\nindex e9d814a34a..a403dd278b 100755\n--- a/t/t9001-send-email.sh\n+++ b/t/t9001-send-email.sh\n@@ -1422,6 +1422,21 @@ test_expect_success $PREREQ 'detects ambiguous reference/file conflict' '\n \ttest_grep disambiguate errors\n '\n \n+test_expect_success $PREREQ 'missing subject omits Perl location' '\n+\tcat >no-subject.patch <<-\\EOF &&\n+\tThis is the body.\n+\tEOF\n+\ttest_must_fail git send-email \\\n+\t\t--dry-run \\\n+\t\t--from=\"Example <nobody@example.com>\" \\\n+\t\t--to=nobody@example.com \\\n+\t\tno-subject.patch 2>actual &&\n+\tcat >expect <<-\\EOF &&\n+\tNo subject line in no-subject.patch. The first line must start with \"Subject: \"\n+\tEOF\n+\ttest_cmp expect actual\n+'\n+\n test_expect_success $PREREQ 'feed two files' '\n \trm -fr outdir &&\n \tgit format-patch -2 -o outdir &&\n\nbase-commit: 010afd3166ddc64c9863b1506f12cbcdda0d4ea1\n-- \ngitgitgadget\n"},{"id":"550132","messageId":"xmqqo6fb85v7.fsf@gitster.g","threadId":"66144","inReplyTo":"pull.2375.git.git.1786267394375.gitgitgadget@gmail.com","subject":"Re: [PATCH] send-email: clarify missing subject error","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2026-08-09T19:13:16Z","receivedAt":"2026-08-09T19:13:19Z","isPatch":true,"body":"\"Harald Nordgren via GitGitGadget\" <gitgitgadget@gmail.com> writes:\n\n> From: Harald Nordgren <haraldnordgren@gmail.com>\n>\n> Explain the required Subject: prefix when a message file has no subject.\n\nYes, get_patch_subject() is called from places where the caller\nwants to determine whether the given file has at least one line that\nbegins with 'Subject:'.  In that case, the subroutine returns the\nrest of that line; if it does not find any such line, it issues an\nerror message and dies.\n\nAs a side note, the check is curiously case-sensitive.  It is also\ncurious that the scanning does not stop at the first blank line that\nterminates the email headers.  However, do not change this behavior\nwithout studying the possible ramifications.  People have learned to\nuse various inputs that are not exactly what is output by 'git\nformat-patch', so rejecting a 'malformed' file simply because it\ndiffers from typical 'git format-patch' output will break someone's\nestablished workflow.\n\n> Terminate the error with a newline so Perl does not append its internal\n> source location.\n\nVery nice spotting.  For an end-user facing script, the source\nlocation is not useful.  The user is not debugging and fixing the\nsend-email script after all ;-).\n\n> diff --git a/git-send-email.perl b/git-send-email.perl\n> index bb8ddd1eef..4d76d53c49 100755\n> --- a/git-send-email.perl\n> +++ b/git-send-email.perl\n> @@ -863,7 +863,8 @@ sub get_patch_subject {\n>  \t\treturn \"GIT: $1\\n\";\n>  \t}\n>  \tclose $fh;\n> -\tdie sprintf(__(\"No subject line in %s?\"), $fn);\n> +\tdie sprintf(__(\"No subject line in %s. \" .\n> +\t\t\"The first line must start with \\\"Subject: \\\"\\n\"), $fn);\n>  }\n\nAn input file to the 'git send-email' program is often the output\nof 'git format-patch'.  Such a file begins with a UNIX 'From '\nline, followed by email headers such as 'From:', 'Date:', and\n'Subject:'.  The 'Subject:' line cannot be the first line of\nthe file in this case, yet it is a valid input.\n\nThe only condition that this subroutine flags as an error is when\nthe file lacks a subject line.  \"No 'Subject:' line in '%s'\\n\" is a\nclear message to display and is an improvement over the original.\n\nHowever, the fact that the first line does not start with\n\"Subject:\" is irrelevant to the basis of the subroutine's\ndecision to issue an error, I think.\n\nThanks.\n"},{"id":"550164","messageId":"CAHwyqnVWgNThSPnPBVwOb11S9MSjD0R3BRg1ci6yEQR+Vn1kXg@mail.gmail.com","threadId":"66144","inReplyTo":"xmqqo6fb85v7.fsf@gitster.g","subject":"Re: [PATCH] send-email: clarify missing subject error","fromName":"Harald Nordgren","fromEmail":"haraldnordgren@gmail.com","sentAt":"2026-08-10T09:48:07Z","receivedAt":"2026-08-10T09:48:46Z","isPatch":true,"body":"> An input file to the 'git send-email' program is often the output\n> of 'git format-patch'.  Such a file begins with a UNIX 'From '\n> line, followed by email headers such as 'From:', 'Date:', and\n> 'Subject:'.  The 'Subject:' line cannot be the first line of\n> the file in this case, yet it is a valid input.\n>\n> The only condition that this subroutine flags as an error is when\n> the file lacks a subject line.  \"No 'Subject:' line in '%s'\\n\" is a\n> clear message to display and is an improvement over the original.\n>\n> However, the fact that the first line does not start with\n> \"Subject:\" is irrelevant to the basis of the subroutine's\n> decision to issue an error, I think.\n\nYeah, that makes sense, so maybe we don't need to focus on it being\nthe first line, but Subject needs to be there somewhere before the\nbody.\n\n\nHarald\n"},{"id":"550197","messageId":"xmqqh5l26ll7.fsf@gitster.g","threadId":"66144","inReplyTo":"CAHwyqnVWgNThSPnPBVwOb11S9MSjD0R3BRg1ci6yEQR+Vn1kXg@mail.gmail.com","subject":"Re: [PATCH] send-email: clarify missing subject error","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2026-08-10T15:28:52Z","receivedAt":"2026-08-10T15:28:55Z","isPatch":true,"body":"Harald Nordgren <haraldnordgren@gmail.com> writes:\n\n>> An input file to the 'git send-email' program is often the output\n>> of 'git format-patch'.  Such a file begins with a UNIX 'From '\n>> line, followed by email headers such as 'From:', 'Date:', and\n>> 'Subject:'.  The 'Subject:' line cannot be the first line of\n>> the file in this case, yet it is a valid input.\n>>\n>> The only condition that this subroutine flags as an error is when\n>> the file lacks a subject line.  \"No 'Subject:' line in '%s'\\n\" is a\n>> clear message to display and is an improvement over the original.\n>>\n>> However, the fact that the first line does not start with\n>> \"Subject:\" is irrelevant to the basis of the subroutine's\n>> decision to issue an error, I think.\n>\n> Yeah, that makes sense, so maybe we don't need to focus on it being\n> the first line, but Subject needs to be there somewhere before the\n> body.\n\nYeah, the curious thing is that the subroutine with the loop is\nhappy as long as it finds \"^Subject: \" somewhere, not necessarily\nbefore the first blank line.\n\nThat is why I said \"No 'Subject: ' line in '%s'\\n\" is clear enough\nand an improvement over the original.  Anything else will add lie to\nit.\n\nThanks.\n"},{"id":"550211","messageId":"pull.2375.v2.git.git.1786384412423.gitgitgadget@gmail.com","threadId":"66144","inReplyTo":"pull.2375.git.git.1786267394375.gitgitgadget@gmail.com","subject":"[PATCH v2] send-email: clarify missing subject error","fromName":"Harald Nordgren via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2026-08-10T17:53:32Z","receivedAt":"2026-08-10T17:53:34Z","isPatch":true,"body":"From: Harald Nordgren <haraldnordgren@gmail.com>\n\nClarify that a message file is missing a 'Subject:' line.\n\nTerminate the error with a newline so Perl does not append its internal\nsource location.\n\nSigned-off-by: Harald Nordgren <haraldnordgren@gmail.com>\n---\n    send-email: clarify missing subject error\n    \n    Explain the required Subject: prefix when a message file has no subject.\n    Terminate the error with a newline so Perl does not append its internal\n    source location.\n    \n    Changes in v2:\n    \n     * Remove the incorrect claim that Subject: must be the first line.\n       Report the missing header directly as No 'Subject:' line in '<file>'.\n\nPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-2375%2FHaraldNordgren%2Ffix%2Fsend-email-subject-error-v2\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-2375/HaraldNordgren/fix/send-email-subject-error-v2\nPull-Request: https://github.com/git/git/pull/2375\n\nRange-diff vs v1:\n\n 1:  fe4171b0dc ! 1:  7002c5d5f1 send-email: clarify missing subject error\n     @@ Metadata\n       ## Commit message ##\n          send-email: clarify missing subject error\n      \n     -    Explain the required Subject: prefix when a message file has no subject.\n     +    Clarify that a message file is missing a 'Subject:' line.\n     +\n          Terminate the error with a newline so Perl does not append its internal\n          source location.\n      \n     @@ git-send-email.perl: sub get_patch_subject {\n       \t}\n       \tclose $fh;\n      -\tdie sprintf(__(\"No subject line in %s?\"), $fn);\n     -+\tdie sprintf(__(\"No subject line in %s. \" .\n     -+\t\t\"The first line must start with \\\"Subject: \\\"\\n\"), $fn);\n     ++\tdie sprintf(__(\"No 'Subject:' line in '%s'\\n\"), $fn);\n       }\n       \n       if ($compose) {\n     @@ t/t9001-send-email.sh: test_expect_success $PREREQ 'detects ambiguous reference/\n      +\t\t--to=nobody@example.com \\\n      +\t\tno-subject.patch 2>actual &&\n      +\tcat >expect <<-\\EOF &&\n     -+\tNo subject line in no-subject.patch. The first line must start with \"Subject: \"\n     ++\tNo '\\''Subject:'\\'' line in '\\''no-subject.patch'\\''\n      +\tEOF\n      +\ttest_cmp expect actual\n      +'\n\n\n git-send-email.perl   |  2 +-\n t/t9001-send-email.sh | 15 +++++++++++++++\n 2 files changed, 16 insertions(+), 1 deletion(-)\n\ndiff --git a/git-send-email.perl b/git-send-email.perl\nindex bb8ddd1eef..2071cff6ae 100755\n--- a/git-send-email.perl\n+++ b/git-send-email.perl\n@@ -863,7 +863,7 @@ sub get_patch_subject {\n \t\treturn \"GIT: $1\\n\";\n \t}\n \tclose $fh;\n-\tdie sprintf(__(\"No subject line in %s?\"), $fn);\n+\tdie sprintf(__(\"No 'Subject:' line in '%s'\\n\"), $fn);\n }\n \n if ($compose) {\ndiff --git a/t/t9001-send-email.sh b/t/t9001-send-email.sh\nindex e9d814a34a..d1393ef197 100755\n--- a/t/t9001-send-email.sh\n+++ b/t/t9001-send-email.sh\n@@ -1422,6 +1422,21 @@ test_expect_success $PREREQ 'detects ambiguous reference/file conflict' '\n \ttest_grep disambiguate errors\n '\n \n+test_expect_success $PREREQ 'missing subject omits Perl location' '\n+\tcat >no-subject.patch <<-\\EOF &&\n+\tThis is the body.\n+\tEOF\n+\ttest_must_fail git send-email \\\n+\t\t--dry-run \\\n+\t\t--from=\"Example <nobody@example.com>\" \\\n+\t\t--to=nobody@example.com \\\n+\t\tno-subject.patch 2>actual &&\n+\tcat >expect <<-\\EOF &&\n+\tNo '\\''Subject:'\\'' line in '\\''no-subject.patch'\\''\n+\tEOF\n+\ttest_cmp expect actual\n+'\n+\n test_expect_success $PREREQ 'feed two files' '\n \trm -fr outdir &&\n \tgit format-patch -2 -o outdir &&\n\nbase-commit: 010afd3166ddc64c9863b1506f12cbcdda0d4ea1\n-- \ngitgitgadget\n"},{"id":"550223","messageId":"xmqqtsp165tj.fsf@gitster.g","threadId":"66144","inReplyTo":"pull.2375.v2.git.git.1786384412423.gitgitgadget@gmail.com","subject":"Re: [PATCH v2] send-email: clarify missing subject error","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2026-08-10T21:09:28Z","receivedAt":"2026-08-10T21:09:30Z","isPatch":true,"body":"\"Harald Nordgren via GitGitGadget\" <gitgitgadget@gmail.com> writes:\n\n> +test_expect_success $PREREQ 'missing subject omits Perl location' '\n> +\tcat >no-subject.patch <<-\\EOF &&\n> +\tThis is the body.\n> +\tEOF\n> +\ttest_must_fail git send-email \\\n> +\t\t--dry-run \\\n> +\t\t--from=\"Example <nobody@example.com>\" \\\n> +\t\t--to=nobody@example.com \\\n> +\t\tno-subject.patch 2>actual &&\n> +\tcat >expect <<-\\EOF &&\n> +\tNo '\\''Subject:'\\'' line in '\\''no-subject.patch'\\''\n> +\tEOF\n\nOK.  We require the message to exactly be this one (not starting\nwith this substring), which makes sure we are not getting the line\nnumbers from die.  Good.\n\nWill queue.  This round looks perfect.  Let's mark it for 'next'.\n\nThanks.\n"}]}