From: Jonathan Tan <jonathantanmy@google.com>
To: Matthew Wilcox <mawilcox@linuxonhyperv.com>, git@vger.kernel.org
Cc: Matthew Wilcox <mawilcox@microsoft.com>
Subject: Re: [PATCH 2/2] mailinfo: Understand forwarded patches
Date: Thu, 12 Jan 2017 10:17:50 -0800 [thread overview]
Message-ID: <866bff14-ea25-c644-b8d2-1529f31e6461@google.com> (raw)
In-Reply-To: <1484212824-14108-2-git-send-email-mawilcox@linuxonhyperv.com>
On 01/12/2017 01:20 AM, Matthew Wilcox wrote:
> 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.
> ---
> 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.
> };
>
> 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?
> + continue;
> + }
> in_perforation = 0;
> }
>
>
next prev parent reply other threads:[~2017-01-12 18:18 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-01-12 9:20 [PATCH 1/2] mailinfo: Add support for keep_cr Matthew Wilcox
2017-01-12 9:20 ` [PATCH 2/2] mailinfo: Understand forwarded patches Matthew Wilcox
2017-01-12 18:17 ` Jonathan Tan [this message]
2017-01-12 19:35 ` Matthew Wilcox
2017-01-12 20:18 ` Junio C Hamano
2017-01-12 18:04 ` [PATCH 1/2] mailinfo: Add support for keep_cr Jonathan Tan
2017-01-12 19:06 ` Matthew Wilcox
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=866bff14-ea25-c644-b8d2-1529f31e6461@google.com \
--to=jonathantanmy@google.com \
--cc=git@vger.kernel.org \
--cc=mawilcox@linuxonhyperv.com \
--cc=mawilcox@microsoft.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).