builtin-am: support and auto-detect StGit series files
[gitweb.git] / t / t4150-am.sh
index 67fbf0e1c94ed247decf6aaa91f963dae7f316a2..e9b6f8158a381de716e41ee2d2e0e6f1c84d5ac5 100755 (executable)
@@ -117,6 +117,38 @@ test_expect_success setup '
                echo "X-Fake-Field: Line Three" &&
                git format-patch --stdout first | sed -e "1d"
        } > patch1-ws.eml &&
+       {
+               sed -ne "1p" msg &&
+               echo &&
+               echo "From: $GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL>" &&
+               echo "Date: $GIT_AUTHOR_DATE" &&
+               echo &&
+               sed -e "1,2d" msg &&
+               echo &&
+               echo "Signed-off-by: $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL>" &&
+               echo "---" &&
+               git diff-tree --no-commit-id --stat -p second
+       } >patch1-stgit.eml &&
+       mkdir stgit-series &&
+       cp patch1-stgit.eml stgit-series/patch &&
+       {
+               echo "# This series applies on GIT commit $(git rev-parse first)" &&
+               echo "patch"
+       } >stgit-series/series &&
+       {
+               echo "# HG changeset patch" &&
+               echo "# User $GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL>" &&
+               echo "# Date $test_tick 25200" &&
+               echo "#      $(git show --pretty="%aD" -s second)" &&
+               echo "# Node ID $_z40" &&
+               echo "# Parent  $_z40" &&
+               cat msg &&
+               echo &&
+               echo "Signed-off-by: $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL>" &&
+               echo &&
+               git diff-tree --no-commit-id -p second
+       } >patch1-hg.eml &&
+
 
        echo scissors-file >scissors-file &&
        git add scissors-file &&
@@ -226,6 +258,56 @@ test_expect_success 'am applies patch e-mail with preceding whitespace' '
        test "$(git rev-parse second^)" = "$(git rev-parse HEAD^)"
 '
 
+test_expect_success 'am applies stgit patch' '
+       rm -fr .git/rebase-apply &&
+       git checkout -f first &&
+       git am patch1-stgit.eml &&
+       test_path_is_missing .git/rebase-apply &&
+       git diff --exit-code second &&
+       test_cmp_rev second HEAD &&
+       test_cmp_rev second^ HEAD^
+'
+
+test_expect_success 'am --patch-format=stgit applies stgit patch' '
+       rm -fr .git/rebase-apply &&
+       git checkout -f first &&
+       git am --patch-format=stgit <patch1-stgit.eml &&
+       test_path_is_missing .git/rebase-apply &&
+       git diff --exit-code second &&
+       test_cmp_rev second HEAD &&
+       test_cmp_rev second^ HEAD^
+'
+
+test_expect_success 'am applies stgit series' '
+       rm -fr .git/rebase-apply &&
+       git checkout -f first &&
+       git am stgit-series/series &&
+       test_path_is_missing .git/rebase-apply &&
+       git diff --exit-code second &&
+       test_cmp_rev second HEAD &&
+       test_cmp_rev second^ HEAD^
+'
+
+test_expect_success 'am applies hg patch' '
+       rm -fr .git/rebase-apply &&
+       git checkout -f first &&
+       git am patch1-hg.eml &&
+       test_path_is_missing .git/rebase-apply &&
+       git diff --exit-code second &&
+       test_cmp_rev second HEAD &&
+       test_cmp_rev second^ HEAD^
+'
+
+test_expect_success 'am --patch-format=hg applies hg patch' '
+       rm -fr .git/rebase-apply &&
+       git checkout -f first &&
+       git am --patch-format=hg <patch1-hg.eml &&
+       test_path_is_missing .git/rebase-apply &&
+       git diff --exit-code second &&
+       test_cmp_rev second HEAD &&
+       test_cmp_rev second^ HEAD^
+'
+
 test_expect_success 'am with applypatch-msg hook' '
        test_when_finished "rm -f .git/hooks/applypatch-msg" &&
        rm -fr .git/rebase-apply &&
@@ -469,25 +551,6 @@ test_expect_success 'am -3 -p0 can read --no-prefix patch' '
        git diff --exit-code lorem
 '
 
-test_expect_success 'am with config am.threeWay falls back to 3-way merge' '
-       rm -fr .git/rebase-apply &&
-       git reset --hard &&
-       git checkout -b lorem4 base3way &&
-       test_config am.threeWay 1 &&
-       git am lorem-move.patch &&
-       test_path_is_missing .git/rebase-apply &&
-       git diff --exit-code lorem
-'
-
-test_expect_success 'am with config am.threeWay overridden by --no-3way' '
-       rm -fr .git/rebase-apply &&
-       git reset --hard &&
-       git checkout -b lorem5 base3way &&
-       test_config am.threeWay 1 &&
-       test_must_fail git am --no-3way lorem-move.patch &&
-       test_path_is_dir .git/rebase-apply
-'
-
 test_expect_success 'am can rename a file' '
        grep "^rename from" rename.patch &&
        rm -fr .git/rebase-apply &&