git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] send-email: clarify missing subject error

From
Junio C Hamano <gitster@pobox.com>
Date
Aug 9, 2026, 19:13 UTC
Message-ID
<xmqqo6fb85v7.fsf@gitster.g>
In-Reply-To
<pull.2375.git.git.1786267394375.gitgitgadget@gmail.com>
"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 ;-).

Show 12 quoted lines
> 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.
Previous: Harald Nordgren via GitGitGadgetNext: Harald Nordgren
Message 2 of 6 in “send-email: clarify missing subject error”
  1. send-email: clarify missing subject errorHarald Nordgren via GitGitGadget, Aug 9, 2026
  2. Junio C HamanoAug 9, 2026
  3. Harald NordgrenAug 10, 2026
  4. Junio C HamanoAug 10, 2026
  5. send-email: clarify missing subject errorHarald Nordgren via GitGitGadget, Aug 10, 2026
  6. Junio C HamanoAug 10, 2026

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.