t4150: test applying StGit patch

By default, an StGit patch separates the subject from the commit message and headers as follows: $subject From: $author_name <$author_email> $message --- $diffstats We test git-am's ability to detect such a patch as an StGit patch, and its ability to be able to extract the commit author, date and message from such a patch. Based-on-patch-by: Chris Packham <judge.packham@gmail.com> Signed-off-by: Paul Tan <pyokagan@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Paul Tan committed Jun 8, 2015 at 23:48 UTC 1daaddd1d3fc92e1766fb5d9701db0418c6813bc
1 file changed +22
t/t4150-am.sh
+22
@@ -104,6 +104,18 @@ test_expect_success setup '
104 echo "X-Fake-Field: Line Three" &&
105 git format-patch --stdout first | sed -e "1d"
106 } > patch1-ws.eml &&
107 + {
108 + sed -ne "1p" msg &&
109 + echo &&
110 + echo "From: $GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL>" &&
111 + echo "Date: $GIT_AUTHOR_DATE" &&
112 + echo &&
113 + sed -e "1,2d" msg &&
114 + echo &&
115 + echo "Signed-off-by: $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL>" &&
116 + echo "---" &&
117 + git diff-tree --no-commit-id --stat -p second
118 + } >patch1-stgit.eml &&
119
120 sed -n -e "3,\$p" msg >file &&
121 git add file &&
@@ -187,6 +199,16 @@ test_expect_success 'am applies patch e-mail with preceding whitespace' '
199 test "$(git rev-parse second^)" = "$(git rev-parse HEAD^)"
200 '
201
202 +test_expect_success 'am applies stgit patch' '
203 + rm -fr .git/rebase-apply &&
204 + git checkout -f first &&
205 + git am patch1-stgit.eml &&
206 + test_path_is_missing .git/rebase-apply &&
207 + git diff --exit-code second &&
208 + test_cmp_rev second HEAD &&
209 + test_cmp_rev second^ HEAD^
210 +'
211 +
212 test_expect_success 'setup: new author and committer' '
213 GIT_AUTHOR_NAME="Another Thor" &&
214 GIT_AUTHOR_EMAIL="a.thor@example.com" &&