t/helper/test-lazy-name-hash: fix compilation
[gitweb.git] / t / t4150-am.sh
index b41bd17264f93d54d5aa280fbc305cebb18950a0..89a5bacac5ad069ec10b16bfdf3dbde7217cf4de 100755 (executable)
@@ -957,4 +957,47 @@ test_expect_success 'am -s unexpected trailer block' '
        test_cmp expect actual
 '
 
+test_expect_success 'am --patch-format=mboxrd handles mboxrd' '
+       rm -fr .git/rebase-apply &&
+       git checkout -f first &&
+       echo mboxrd >>file &&
+       git add file &&
+       cat >msg <<-\INPUT_END &&
+       mboxrd should escape the body
+
+       From could trip up a loose mbox parser
+       >From extra escape for reversibility
+       INPUT_END
+       git commit -F msg &&
+       git format-patch --pretty=mboxrd --stdout -1 >mboxrd1 &&
+       grep "^>From could trip up a loose mbox parser" mboxrd1 &&
+       git checkout -f first &&
+       git am --patch-format=mboxrd mboxrd1 &&
+       git cat-file commit HEAD | tail -n4 >out &&
+       test_cmp msg out
+'
+
+test_expect_success 'am works with multi-line in-body headers' '
+       FORTY="String that has a length of more than forty characters" &&
+       LONG="$FORTY $FORTY" &&
+       rm -fr .git/rebase-apply &&
+       git checkout -f first &&
+       echo one >> file &&
+       git commit -am "$LONG" --author="$LONG <long@example.com>" &&
+       git format-patch --stdout -1 >patch &&
+       # bump from, date, and subject down to in-body header
+       perl -lpe "
+               if (/^From:/) {
+                       print \"From: x <x\@example.com>\";
+                       print \"Date: Sat, 1 Jan 2000 00:00:00 +0000\";
+                       print \"Subject: x\n\";
+               }
+       " patch >msg &&
+       git checkout HEAD^ &&
+       git am msg &&
+       # Ensure that the author and full message are present
+       git cat-file commit HEAD | grep "^author.*long@example.com" &&
+       git cat-file commit HEAD | grep "^$LONG"
+'
+
 test_done