Code

Merge branch 'os/fix-rebase-diff-no-prefix'
[git.git] / t / t3508-cherry-pick-many-commits.sh
index d90b365fd2efbe24f877d6695b87996f618963e4..8e09fd0319c95cbd4d30c461f00fee5f52e27cbd 100755 (executable)
@@ -4,6 +4,18 @@ test_description='test cherry-picking many commits'
 
 . ./test-lib.sh
 
+check_head_differs_from() {
+       head=$(git rev-parse --verify HEAD) &&
+       arg=$(git rev-parse --verify "$1") &&
+       test "$head" != "$arg"
+}
+
+check_head_equals() {
+       head=$(git rev-parse --verify HEAD) &&
+       arg=$(git rev-parse --verify "$1") &&
+       test "$head" = "$arg"
+}
+
 test_expect_success setup '
        echo first > file1 &&
        git add file1 &&
@@ -24,36 +36,54 @@ test_expect_success setup '
 
 test_expect_success 'cherry-pick first..fourth works' '
        cat <<-\EOF >expected &&
-       Finished one cherry-pick.
-       Finished one cherry-pick.
-       Finished one cherry-pick.
+       [master OBJID] second
+        Author: A U Thor <author@example.com>
+        1 files changed, 1 insertions(+), 0 deletions(-)
+       [master OBJID] third
+        Author: A U Thor <author@example.com>
+        1 files changed, 1 insertions(+), 0 deletions(-)
+       [master OBJID] fourth
+        Author: A U Thor <author@example.com>
+        1 files changed, 1 insertions(+), 0 deletions(-)
        EOF
 
        git checkout -f master &&
        git reset --hard first &&
        test_tick &&
-       git cherry-pick first..fourth 2>actual &&
+       git cherry-pick first..fourth >actual &&
        git diff --quiet other &&
        git diff --quiet HEAD other &&
-       test_cmp expected actual &&
-       test "$(git rev-parse --verify HEAD)" != "$(git rev-parse --verify fourth)"
+
+       sed -e "s/$_x05[0-9a-f][0-9a-f]/OBJID/" <actual >actual.fuzzy &&
+       test_cmp expected actual.fuzzy &&
+       check_head_differs_from fourth
 '
 
 test_expect_success 'cherry-pick --strategy resolve first..fourth works' '
        cat <<-\EOF >expected &&
-       Finished one cherry-pick with strategy resolve.
-       Finished one cherry-pick with strategy resolve.
-       Finished one cherry-pick with strategy resolve.
+       Trying simple merge.
+       [master OBJID] second
+        Author: A U Thor <author@example.com>
+        1 files changed, 1 insertions(+), 0 deletions(-)
+       Trying simple merge.
+       [master OBJID] third
+        Author: A U Thor <author@example.com>
+        1 files changed, 1 insertions(+), 0 deletions(-)
+       Trying simple merge.
+       [master OBJID] fourth
+        Author: A U Thor <author@example.com>
+        1 files changed, 1 insertions(+), 0 deletions(-)
        EOF
 
        git checkout -f master &&
        git reset --hard first &&
        test_tick &&
-       git cherry-pick --strategy resolve first..fourth 2>actual &&
+       git cherry-pick --strategy resolve first..fourth >actual &&
        git diff --quiet other &&
        git diff --quiet HEAD other &&
-       test_cmp expected actual &&
-       test "$(git rev-parse --verify HEAD)" != "$(git rev-parse --verify fourth)"
+       sed -e "s/$_x05[0-9a-f][0-9a-f]/OBJID/" <actual >actual.fuzzy &&
+       test_cmp expected actual.fuzzy &&
+       check_head_differs_from fourth
 '
 
 test_expect_success 'cherry-pick --ff first..fourth works' '
@@ -63,7 +93,7 @@ test_expect_success 'cherry-pick --ff first..fourth works' '
        git cherry-pick --ff first..fourth &&
        git diff --quiet other &&
        git diff --quiet HEAD other &&
-       test "$(git rev-parse --verify HEAD)" = "$(git rev-parse --verify fourth)"
+       check_head_equals fourth
 '
 
 test_expect_success 'cherry-pick -n first..fourth works' '
@@ -113,7 +143,7 @@ test_expect_success 'cherry-pick -3 fourth works' '
        git cherry-pick -3 fourth &&
        git diff --quiet other &&
        git diff --quiet HEAD other &&
-       test "$(git rev-parse --verify HEAD)" != "$(git rev-parse --verify fourth)"
+       check_head_differs_from fourth
 '
 
 test_expect_success 'cherry-pick --stdin works' '
@@ -123,7 +153,7 @@ test_expect_success 'cherry-pick --stdin works' '
        git rev-list --reverse first..fourth | git cherry-pick --stdin &&
        git diff --quiet other &&
        git diff --quiet HEAD other &&
-       test "$(git rev-parse --verify HEAD)" != "$(git rev-parse --verify fourth)"
+       check_head_differs_from fourth
 '
 
 test_done