pretty: add support for separator option in %(trailers)
[gitweb.git] / t / t4014-format-patch.sh
index dac3f349a3247004d9375a0f6f96befc5c00cf9c..909c743c134c5e18e0a80db3eae2dfb6e8210e6a 100755 (executable)
@@ -578,7 +578,11 @@ test_expect_success 'excessive subject' '
 
        rm -rf patches/ &&
        git checkout side &&
+       before=$(git hash-object file) &&
+       before=$(git rev-parse --short $before) &&
        for i in 5 6 1 2 3 A 4 B C 7 8 9 10 D E F; do echo "$i"; done >>file &&
+       after=$(git hash-object file) &&
+       after=$(git rev-parse --short $after) &&
        git update-index file &&
        git commit -m "This is an excessively long subject line for a message due to the habit some projects have of not having a short, one-line subject at the start of the commit message, but rather sticking a whole paragraph right at the start as the only thing in the commit message. It had better not become the filename for the patch." &&
        git format-patch -o patches/ master..side &&
@@ -586,7 +590,6 @@ test_expect_success 'excessive subject' '
 '
 
 test_expect_success 'cover-letter inherits diff options' '
-
        git mv file foo &&
        git commit -m foo &&
        git format-patch --no-renames --cover-letter -1 &&
@@ -616,7 +619,7 @@ test_expect_success 'shortlog of cover-letter wraps overly-long onelines' '
 '
 
 cat > expect << EOF
-index 40f36c6..2dc5c23 100644
+index $before..$after 100644
 --- a/file
 +++ b/file
 @@ -13,4 +13,20 @@ C
@@ -640,7 +643,7 @@ test_expect_success 'format-patch respects -U' '
 cat > expect << EOF
 
 diff --git a/file b/file
-index 40f36c6..2dc5c23 100644
+index $before..$after 100644
 --- a/file
 +++ b/file
 @@ -14,3 +14,19 @@ C
@@ -1551,13 +1554,15 @@ test_expect_success 'format-patch -o overrides format.outputDirectory' '
 
 test_expect_success 'format-patch --base' '
        git checkout side &&
-       git format-patch --stdout --base=HEAD~3 -1 | tail -n 7 >actual &&
+       git format-patch --stdout --base=HEAD~3 -1 | tail -n 7 >actual1 &&
+       git format-patch --stdout --base=HEAD~3 HEAD~.. | tail -n 7 >actual2 &&
        echo >expected &&
        echo "base-commit: $(git rev-parse HEAD~3)" >>expected &&
        echo "prerequisite-patch-id: $(git show --patch HEAD~2 | git patch-id --stable | awk "{print \$1}")" >>expected &&
        echo "prerequisite-patch-id: $(git show --patch HEAD~1 | git patch-id --stable | awk "{print \$1}")" >>expected &&
        signature >> expected &&
-       test_cmp expected actual
+       test_cmp expected actual1 &&
+       test_cmp expected actual2
 '
 
 test_expect_success 'format-patch --base errors out when base commit is in revision list' '
@@ -1661,6 +1666,15 @@ test_expect_success 'format-patch --base with --attach' '
        test_write_lines 1 2 >expect &&
        test_cmp expect actual
 '
+test_expect_success 'format-patch --attach cover-letter only is non-multipart' '
+       test_when_finished "rm -fr patches" &&
+       git format-patch -o patches --cover-letter --attach=mimemime --base=HEAD~ -1 &&
+       ! egrep "^--+mimemime" patches/0000*.patch &&
+       egrep "^--+mimemime$" patches/0001*.patch >output &&
+       test_line_count = 2 output &&
+       egrep "^--+mimemime--$" patches/0001*.patch >output &&
+       test_line_count = 1 output
+'
 
 test_expect_success 'format-patch --pretty=mboxrd' '
        sp=" " &&
@@ -1703,4 +1717,38 @@ test_expect_success 'format-patch --pretty=mboxrd' '
        test_cmp expect actual
 '
 
+test_expect_success 'interdiff: setup' '
+       git checkout -b boop master &&
+       test_commit fnorp blorp &&
+       test_commit fleep blorp
+'
+
+test_expect_success 'interdiff: cover-letter' '
+       sed "y/q/ /" >expect <<-\EOF &&
+       +fleep
+       --q
+       EOF
+       git format-patch --cover-letter --interdiff=boop~2 -1 boop &&
+       test_i18ngrep "^Interdiff:$" 0000-cover-letter.patch &&
+       test_i18ngrep ! "^Interdiff:$" 0001-fleep.patch &&
+       sed "1,/^@@ /d; /^-- $/q" <0000-cover-letter.patch >actual &&
+       test_cmp expect actual
+'
+
+test_expect_success 'interdiff: reroll-count' '
+       git format-patch --cover-letter --interdiff=boop~2 -v2 -1 boop &&
+       test_i18ngrep "^Interdiff ..* v1:$" v2-0000-cover-letter.patch
+'
+
+test_expect_success 'interdiff: solo-patch' '
+       cat >expect <<-\EOF &&
+         +fleep
+
+       EOF
+       git format-patch --interdiff=boop~2 -1 boop &&
+       test_i18ngrep "^Interdiff:$" 0001-fleep.patch &&
+       sed "1,/^  @@ /d; /^$/q" <0001-fleep.patch >actual &&
+       test_cmp expect actual
+'
+
 test_done