[PATCH 2/2] Add test from From_-line escaping.
From: Carl Worth <hidden>
Date: 2016-06-15 22:48:56
Subsystem:
the rest · Maintainer:
Linus Torvalds
As implemented in the previous commit. We test that when applying from an mbox that all escaped From_ lines are properly unescaped. We also test that when applying from an email message the unescaping does not occur. Signed-off-by: Carl Worth <redacted> --- t/t4152-am-From_.sh | 64 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 64 insertions(+), 0 deletions(-) create mode 100755 t/t4152-am-From_.sh
diff --git a/t/t4152-am-From_.sh b/t/t4152-am-From_.sh
new file mode 100755
index 0000000..02821ee
--- /dev/null
+++ b/t/t4152-am-From_.sh@@ -0,0 +1,64 @@ +#!/bin/sh + +test_description='git am properly unescaping From_ lines' + +. ./test-lib.sh + +cat >msg <<EOF +From_ lines + +This is a commit message that contains a From_ line, which is line +that begins with the characters "From ". Get ready for it, now... +From this time forward, we'll have no From_-line bugs. + +Additionally, we'll also test lines that are escaped versions of From_ +lines. These are lines that begin with one or more '>' characters that +are then followed by the characters "From ". We want to ensure that +none of these intentional '>' characters get swallowed. Let's try that +with three variations, (with 1, 2, and 3 leading '>' characters): + +>From now on (with one leading '>') +>>From there to here (with two leading '>' characters) +>>>From Here to Eternity (with three leading '>' characters) + +EOF + +test_expect_success setup ' + echo hello >file && + git add file && + test_tick && + git commit -m first && + git tag first && + echo world >>file && + git add file && + test_tick && + git commit -s -F msg && + git tag second && + git format-patch --stdout first | sed -e "1{p;d};s/^\(>*From \)/>\1/" > From_ && + { + echo "X-Fake-Field: Line One" && + echo "X-Fake-Field: Line Two" && + echo "X-Fake-Field: Line Three" && + git format-patch --stdout first | sed -e "1d" + } > From_.eml +' + +test_expect_success 'am unescapes From_ lines from mbox' ' + git checkout first && + git am From_ && + ! test -d .git/rebase-apply && + test -z "$(git diff second)" && + test "$(git rev-parse second)" = "$(git rev-parse HEAD)" && + test "$(git rev-parse second^)" = "$(git rev-parse HEAD^)" +' + +test_expect_success 'am does not unescape From_ lines from email' ' + git checkout first && + git am From_.eml && + ! test -d .git/rebase-apply && + test -z "$(git diff second)" && + test "$(git rev-parse second)" = "$(git rev-parse HEAD)" && + test "$(git rev-parse second^)" = "$(git rev-parse HEAD^)" +' + +test_done
--
1.7.0.4