summaryrefslogtreecommitdiff
path: root/builtin
diff options
context:
space:
mode:
authorLibravatar Junio C Hamano <gitster@pobox.com>2014-09-29 12:36:15 -0700
committerLibravatar Junio C Hamano <gitster@pobox.com>2014-09-29 12:36:15 -0700
commit26d058738963f23826d77017e82842331af0bae6 (patch)
tree5c6711249b5bedbd679851d45f6e3313d770af0b /builtin
parentMerge branch 'sb/t6031-typofix' (diff)
parentmailinfo: work around -Wstring-plus-int warning (diff)
downloadtgif-26d058738963f23826d77017e82842331af0bae6.tar.xz
Merge branch 'jk/mbox-from-line'
Some MUAs mangled a line in a message that begins with "From " to ">From " when writing to a mailbox file and feeding such an input to "git am" used to lose such a line. * jk/mbox-from-line: mailinfo: work around -Wstring-plus-int warning mailinfo: make ">From" in-body header check more robust
Diffstat (limited to 'builtin')
-rw-r--r--builtin/mailinfo.c18
1 files changed, 17 insertions, 1 deletions
diff --git a/builtin/mailinfo.c b/builtin/mailinfo.c
index cf11c8d607..6a14d2985d 100644
--- a/builtin/mailinfo.c
+++ b/builtin/mailinfo.c
@@ -288,6 +288,22 @@ static inline int cmp_header(const struct strbuf *line, const char *hdr)
line->buf[len] == ':' && isspace(line->buf[len + 1]);
}
+static int is_format_patch_separator(const char *line, int len)
+{
+ static const char SAMPLE[] =
+ "From e6807f3efca28b30decfecb1732a56c7db1137ee Mon Sep 17 00:00:00 2001\n";
+ const char *cp;
+
+ if (len != strlen(SAMPLE))
+ return 0;
+ if (!skip_prefix(line, "From ", &cp))
+ return 0;
+ if (strspn(cp, "0123456789abcdef") != 40)
+ return 0;
+ cp += 40;
+ return !memcmp(SAMPLE + (cp - line), cp, strlen(SAMPLE) - (cp - line));
+}
+
static int check_header(const struct strbuf *line,
struct strbuf *hdr_data[], int overwrite)
{
@@ -329,7 +345,7 @@ static int check_header(const struct strbuf *line,
/* for inbody stuff */
if (starts_with(line->buf, ">From") && isspace(line->buf[5])) {
- ret = 1; /* Should this return 0? */
+ ret = is_format_patch_separator(line->buf + 1, line->len - 1);
goto check_header_out;
}
if (starts_with(line->buf, "[PATCH]") && isspace(line->buf[7])) {