summaryrefslogtreecommitdiff
path: root/t/t5100-mailinfo.sh
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2014-09-13 21:30:38 -0400
committerJunio C Hamano <gitster@pobox.com>2014-09-16 11:05:46 -0700
commit2da1f36671c3e3e28eba6a56d92249b6671c07d3 (patch)
treebbb858c3e6190eed37c8ef9115c78e082707d645 /t/t5100-mailinfo.sh
parent96db324a73fdada6fbe7b63221986f8f18cc63b0 (diff)
downloadgit-2da1f36671c3e3e28eba6a56d92249b6671c07d3.tar.gz
mailinfo: make ">From" in-body header check more robust
Since commit 81c5cf7 (mailinfo: skip bogus UNIX From line inside body, 2006-05-21), we have treated lines like ">From" in the body as headers. This makes "git am" work for people who erroneously paste the whole output from format-patch: From 12345abcd...fedcba543210 Mon Sep 17 00:00:00 2001 From: them Subject: [PATCH] whatever into their email body (assuming that an mbox writer then quotes "From" as ">From", as otherwise we would actually mailsplit on the in-body line). However, this has false positives if somebody actually has a commit body that starts with "From "; in this case we erroneously remove the line entirely from the commit message. We can make this check more robust by making sure the line actually looks like a real mbox "From" line. Inspect the line that begins with ">From " a more carefully to only skip lines that match the expected pattern (note that the datestamp part of the format-patch output is designed to be kept constant to help those who write magic(5) entries). Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t5100-mailinfo.sh')
-rwxr-xr-xt/t5100-mailinfo.sh18
1 files changed, 18 insertions, 0 deletions
diff --git a/t/t5100-mailinfo.sh b/t/t5100-mailinfo.sh
index 3e64a7a65d..9e1ad1ca21 100755
--- a/t/t5100-mailinfo.sh
+++ b/t/t5100-mailinfo.sh
@@ -89,4 +89,22 @@ test_expect_success 'mailinfo on from header without name works' '
'
+test_expect_success 'mailinfo finds headers after embedded From line' '
+ mkdir embed-from &&
+ git mailsplit -oembed-from "$TEST_DIRECTORY"/t5100/embed-from.in &&
+ test_cmp "$TEST_DIRECTORY"/t5100/embed-from.in embed-from/0001 &&
+ git mailinfo embed-from/msg embed-from/patch \
+ <embed-from/0001 >embed-from/out &&
+ test_cmp "$TEST_DIRECTORY"/t5100/embed-from.expect embed-from/out
+'
+
+test_expect_success 'mailinfo on message with quoted >From' '
+ mkdir quoted-from &&
+ git mailsplit -oquoted-from "$TEST_DIRECTORY"/t5100/quoted-from.in &&
+ test_cmp "$TEST_DIRECTORY"/t5100/quoted-from.in quoted-from/0001 &&
+ git mailinfo quoted-from/msg quoted-from/patch \
+ <quoted-from/0001 >quoted-from/out &&
+ test_cmp "$TEST_DIRECTORY"/t5100/quoted-from.expect quoted-from/msg
+'
+
test_done