tests (rebase): spell out the `--keep-empty` option
[gitweb.git] / t / t3901-i18n-patch.sh
index a392f3d1d66757361ff9fc4e26f4125da5ab0a4f..923eb01f0ea4bec0d3a7d96a2492a0755ad00ef9 100755 (executable)
@@ -9,7 +9,7 @@ test_description='i18n settings and format-patch | am pipe'
 
 check_encoding () {
        # Make sure characters are not corrupted
-       cnt="$1" header="$2" i=1 j=0 bad=0
+       cnt="$1" header="$2" i=1 j=0
        while test "$i" -le $cnt
        do
                git format-patch --encoding=UTF-8 --stdout HEAD~$i..HEAD~$j |
@@ -20,14 +20,10 @@ check_encoding () {
                        grep "^encoding ISO8859-1" ;;
                *)
                        grep "^encoding ISO8859-1"; test "$?" != 0 ;;
-               esac || {
-                       bad=1
-                       break
-               }
+               esac || return 1
                j=$i
                i=$(($i+1))
        done
-       (exit $bad)
 }
 
 test_expect_success setup '
@@ -35,7 +31,7 @@ test_expect_success setup '
 
        # use UTF-8 in author and committer name to match the
        # i18n.commitencoding settings
-       . "$TEST_DIRECTORY"/t3901-utf8.txt &&
+       . "$TEST_DIRECTORY"/t3901/utf8.txt &&
 
        test_tick &&
        echo "$GIT_AUTHOR_NAME" >mine &&
@@ -59,7 +55,7 @@ test_expect_success setup '
                # the second one on the side branch is ISO-8859-1
                git config i18n.commitencoding ISO8859-1 &&
                # use author and committer name in ISO-8859-1 to match it.
-               . "$TEST_DIRECTORY"/t3901-8859-1.txt
+               . "$TEST_DIRECTORY"/t3901/8859-1.txt
        fi &&
        test_tick &&
        echo Yet another >theirs &&
@@ -104,7 +100,7 @@ test_expect_success 'rebase (U/U)' '
 
        # The result will be committed by GIT_COMMITTER_NAME --
        # we want UTF-8 encoded name.
-       . "$TEST_DIRECTORY"/t3901-utf8.txt &&
+       . "$TEST_DIRECTORY"/t3901/utf8.txt &&
        git checkout -b test &&
        git rebase master &&
 
@@ -114,7 +110,7 @@ test_expect_success 'rebase (U/U)' '
 test_expect_success 'rebase (U/L)' '
        git config i18n.commitencoding UTF-8 &&
        git config i18n.logoutputencoding ISO8859-1 &&
-       . "$TEST_DIRECTORY"/t3901-utf8.txt &&
+       . "$TEST_DIRECTORY"/t3901/utf8.txt &&
 
        git reset --hard side &&
        git rebase master &&
@@ -126,7 +122,7 @@ test_expect_success !MINGW 'rebase (L/L)' '
        # In this test we want ISO-8859-1 encoded commits as the result
        git config i18n.commitencoding ISO8859-1 &&
        git config i18n.logoutputencoding ISO8859-1 &&
-       . "$TEST_DIRECTORY"/t3901-8859-1.txt &&
+       . "$TEST_DIRECTORY"/t3901/8859-1.txt &&
 
        git reset --hard side &&
        git rebase master &&
@@ -139,7 +135,7 @@ test_expect_success !MINGW 'rebase (L/U)' '
        # to get ISO-8859-1 results.
        git config i18n.commitencoding ISO8859-1 &&
        git config i18n.logoutputencoding UTF-8 &&
-       . "$TEST_DIRECTORY"/t3901-8859-1.txt &&
+       . "$TEST_DIRECTORY"/t3901/8859-1.txt &&
 
        git reset --hard side &&
        git rebase master &&
@@ -152,7 +148,7 @@ test_expect_success 'cherry-pick(U/U)' '
 
        git config i18n.commitencoding UTF-8 &&
        git config i18n.logoutputencoding UTF-8 &&
-       . "$TEST_DIRECTORY"/t3901-utf8.txt &&
+       . "$TEST_DIRECTORY"/t3901/utf8.txt &&
 
        git reset --hard master &&
        git cherry-pick side^ &&
@@ -167,7 +163,7 @@ test_expect_success !MINGW 'cherry-pick(L/L)' '
 
        git config i18n.commitencoding ISO8859-1 &&
        git config i18n.logoutputencoding ISO8859-1 &&
-       . "$TEST_DIRECTORY"/t3901-8859-1.txt &&
+       . "$TEST_DIRECTORY"/t3901/8859-1.txt &&
 
        git reset --hard master &&
        git cherry-pick side^ &&
@@ -182,7 +178,7 @@ test_expect_success 'cherry-pick(U/L)' '
 
        git config i18n.commitencoding UTF-8 &&
        git config i18n.logoutputencoding ISO8859-1 &&
-       . "$TEST_DIRECTORY"/t3901-utf8.txt &&
+       . "$TEST_DIRECTORY"/t3901/utf8.txt &&
 
        git reset --hard master &&
        git cherry-pick side^ &&
@@ -198,7 +194,7 @@ test_expect_success !MINGW 'cherry-pick(L/U)' '
 
        git config i18n.commitencoding ISO8859-1 &&
        git config i18n.logoutputencoding UTF-8 &&
-       . "$TEST_DIRECTORY"/t3901-8859-1.txt &&
+       . "$TEST_DIRECTORY"/t3901/8859-1.txt &&
 
        git reset --hard master &&
        git cherry-pick side^ &&
@@ -211,7 +207,7 @@ test_expect_success !MINGW 'cherry-pick(L/U)' '
 test_expect_success 'rebase --merge (U/U)' '
        git config i18n.commitencoding UTF-8 &&
        git config i18n.logoutputencoding UTF-8 &&
-       . "$TEST_DIRECTORY"/t3901-utf8.txt &&
+       . "$TEST_DIRECTORY"/t3901/utf8.txt &&
 
        git reset --hard side &&
        git rebase --merge master &&
@@ -222,7 +218,7 @@ test_expect_success 'rebase --merge (U/U)' '
 test_expect_success 'rebase --merge (U/L)' '
        git config i18n.commitencoding UTF-8 &&
        git config i18n.logoutputencoding ISO8859-1 &&
-       . "$TEST_DIRECTORY"/t3901-utf8.txt &&
+       . "$TEST_DIRECTORY"/t3901/utf8.txt &&
 
        git reset --hard side &&
        git rebase --merge master &&
@@ -234,7 +230,7 @@ test_expect_success 'rebase --merge (L/L)' '
        # In this test we want ISO-8859-1 encoded commits as the result
        git config i18n.commitencoding ISO8859-1 &&
        git config i18n.logoutputencoding ISO8859-1 &&
-       . "$TEST_DIRECTORY"/t3901-8859-1.txt &&
+       . "$TEST_DIRECTORY"/t3901/8859-1.txt &&
 
        git reset --hard side &&
        git rebase --merge master &&
@@ -247,7 +243,7 @@ test_expect_success 'rebase --merge (L/U)' '
        # to get ISO-8859-1 results.
        git config i18n.commitencoding ISO8859-1 &&
        git config i18n.logoutputencoding UTF-8 &&
-       . "$TEST_DIRECTORY"/t3901-8859-1.txt &&
+       . "$TEST_DIRECTORY"/t3901/8859-1.txt &&
 
        git reset --hard side &&
        git rebase --merge master &&
@@ -255,4 +251,66 @@ test_expect_success 'rebase --merge (L/U)' '
        check_encoding 2 8859
 '
 
+test_expect_success 'am (U/U)' '
+       # Apply UTF-8 patches with UTF-8 commitencoding
+       git config i18n.commitencoding UTF-8 &&
+       . "$TEST_DIRECTORY"/t3901/utf8.txt &&
+
+       git reset --hard master &&
+       git am out-u1 out-u2 &&
+
+       check_encoding 2
+'
+
+test_expect_success !MINGW 'am (L/L)' '
+       # Apply ISO-8859-1 patches with ISO-8859-1 commitencoding
+       git config i18n.commitencoding ISO8859-1 &&
+       . "$TEST_DIRECTORY"/t3901/8859-1.txt &&
+
+       git reset --hard master &&
+       git am out-l1 out-l2 &&
+
+       check_encoding 2 8859
+'
+
+test_expect_success 'am (U/L)' '
+       # Apply ISO-8859-1 patches with UTF-8 commitencoding
+       git config i18n.commitencoding UTF-8 &&
+       . "$TEST_DIRECTORY"/t3901/utf8.txt &&
+       git reset --hard master &&
+
+       # am specifies --utf8 by default.
+       git am out-l1 out-l2 &&
+
+       check_encoding 2
+'
+
+test_expect_success 'am --no-utf8 (U/L)' '
+       # Apply ISO-8859-1 patches with UTF-8 commitencoding
+       git config i18n.commitencoding UTF-8 &&
+       . "$TEST_DIRECTORY"/t3901/utf8.txt &&
+
+       git reset --hard master &&
+       git am --no-utf8 out-l1 out-l2 2>err &&
+
+       # commit-tree will warn that the commit message does not contain valid UTF-8
+       # as mailinfo did not convert it
+       test_i18ngrep "did not conform" err &&
+
+       check_encoding 2
+'
+
+test_expect_success !MINGW 'am (L/U)' '
+       # Apply UTF-8 patches with ISO-8859-1 commitencoding
+       git config i18n.commitencoding ISO8859-1 &&
+       . "$TEST_DIRECTORY"/t3901/8859-1.txt &&
+
+       git reset --hard master &&
+       # mailinfo will re-code the commit message to the charset specified by
+       # i18n.commitencoding
+       git am out-u1 out-u2 &&
+
+       check_encoding 2 8859
+'
+
 test_done