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

Re: [PATCH 2/2] mailinfo: Understand forwarded patches

From
JTJonathan Tan <jonathantanmy@google.com>
Date
Jan 12, 2017, 18:17 UTC
Message-ID
<866bff14-ea25-c644-b8d2-1529f31e6461@google.com>
In-Reply-To
<1484212824-14108-2-git-send-email-mawilcox@linuxonhyperv.com>
On 01/12/2017 01:20 AM, Matthew Wilcox wrote:
Show 9 quoted lines
> From: Matthew Wilcox <mawilcox@microsoft.com>
>
> Extend the --scissors mechanism to strip off the preamble created by
> forwarding a patch.  There are a couple of extra headers ("Sent" and
> "To") added by forwarding, but other than that, the --scissors option
> will now remove patches forwarded from Microsoft Outlook to a Linux
> email account.
>
> Signed-off-by: Matthew Wilcox <mawilcox@microsoft.com>

Also add a test showing the kind of message that the current code doesn't handle, and that this commit addresses.

Show 14 quoted lines
> ---
>  mailinfo.c | 9 ++++++++-
>  1 file changed, 8 insertions(+), 1 deletion(-)
>
> diff --git a/mailinfo.c b/mailinfo.c
> index 2059704a8..fc1275532 100644
> --- a/mailinfo.c
> +++ b/mailinfo.c
> @@ -332,7 +332,7 @@ static void cleanup_subject(struct mailinfo *mi, struct strbuf *subject)
>
>  #define MAX_HDR_PARSED 10
>  static const char *header[MAX_HDR_PARSED] = {
> -	"From","Subject","Date",
> +	"From","Subject","Date","Sent","To",

Are these extra headers used in both the "real" e-mail headers and the in-body headers, or only one of them? (If the latter, they should probably be handled only in the relevant function - my previous patches to this file were in that direction too, if I remember correctly.) Also, I suspect that these will have to be handled differently to the other 3, but that will be clearer when you add the test with an example message.

Show 8 quoted lines
>  };
>
>  static inline int cmp_header(const struct strbuf *line, const char *hdr)
> @@ -685,6 +685,13 @@ static int is_scissors_line(const char *line)
>  			c++;
>  			continue;
>  		}
> +		if (!memcmp(c, "Original Message", 16)) {
1) You can use starts_with or skip_prefix.
2) This seems vulnerable to false positives. If "Original Message" 
always follows a certain kind of line, it might be better to check for 
that. (Again, it will be clearer when we have an example message.)
> +			in_perforation = 1;
> +			perforation += 16;
> +			scissors += 16;
> +			c += 15;
Why 15? Also, can skip_prefix avoid these magic numbers?
Show 6 quoted lines
> +			continue;
> +		}
>  		in_perforation = 0;
>  	}
>
>
Previous: Matthew WilcoxNext: Matthew Wilcox
Message 3 of 7 in “mailinfo: Add support for keep_cr”
  1. 1/2 mailinfo: Add support for keep_crMatthew Wilcox, Jan 12, 2017
  2. 2/2 mailinfo: Understand forwarded patchesMatthew Wilcox, Jan 12, 2017
  3. Jonathan TanJan 12, 2017
  4. Matthew WilcoxJan 12, 2017
  5. Junio C HamanoJan 12, 2017
  6. Jonathan TanJan 12, 2017
  7. Matthew WilcoxJan 12, 2017

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.