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

Re: [PATCH] git-imap-send bugfix: Allow lines starting with "From " in body

From
Junio C Hamano <gitster@pobox.com>
Date
Mar 21, 2010, 22:05 UTC
Message-ID
<7vwrx5gwjz.fsf@alter.siamese.dyndns.org>
In-Reply-To
<f3271551003211147x538d7682wc67dcc4f914ed97c@mail.gmail.com>
Ramkumar Ramachandra <artagnon@gmail.com> writes:
Show 17 quoted lines
> diff --git a/imap-send.c b/imap-send.c
> index aeb2985..3163bb9 100644
> --- a/imap-send.c
> +++ b/imap-send.c
> @@ -1431,8 +1431,14 @@ static int count_messages(struct msg_data *msg)
>
>  	while (1) {
>  		if (!prefixcmp(p, "From ")) {
> +			p = strstr(p+5, "\nFrom: ");
> +			if (!p) break;
> +			p = strstr(p+7, "\nDate: ");
> +			if (!p) break;
> +			p = strstr(p+7, "\nSubject: ");
> +			if (!p) break;
>  			count++;
> -			p += 5;
> +			p += 10;

The last "increment by 10" is logically tied to the last string being checked happens to be "\nSubject: ", so I would prefer to have the "increment count" be done after that. That way you will keep logically close things physically close together.

As "git help imap-send" clearly says that this command is intended to be used on output from format-patch (but it actually does not say "and nothing else", which it should for your patch to make sense), I think the code is allowed to assume _some_ fixed order of the header fields. It would break people's existing abuse to use imap-send to stuff random pieces of messages in mbox to their IMAP server, though.

But does format-patch _always_ start each message with these and only with these fields in this order? Where would Message-Id:, References:, and Cc: come when the user told format-patch to add them?

Previous: Ramkumar RamachandraNext: Ramkumar Ramachandra
Message 2 of 3 in “git-imap-send bugfix: Allow lines starting with "From " in body”
  1. git-imap-send bugfix: Allow lines starting with "From " in bodyRamkumar Ramachandra, Mar 21, 2010
  2. Junio C HamanoMar 21, 2010
  3. Ramkumar RamachandraMar 22, 2010

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.