Imported Upstream version 2.18.4
[platform/upstream/git.git] / t / t3510-cherry-pick-sequence.sh
index 7b7a89d..b42cd66 100755 (executable)
@@ -122,7 +122,7 @@ test_expect_success '--quit keeps HEAD and conflicted index intact' '
        {
                git rev-list HEAD |
                git diff-tree --root --stdin |
-               sed "s/$_x40/OBJID/g"
+               sed "s/$OID_REGEX/OBJID/g"
        } >actual &&
        test_cmp expect actual
 '
@@ -147,6 +147,16 @@ test_expect_success '--abort to cancel single cherry-pick' '
        git diff-index --exit-code HEAD
 '
 
+test_expect_success '--abort does not unsafely change HEAD' '
+       pristine_detach initial &&
+       test_must_fail git cherry-pick picked anotherpick &&
+       git reset --hard base &&
+       test_must_fail git cherry-pick picked anotherpick &&
+       git cherry-pick --abort 2>actual &&
+       test_i18ngrep "You seem to have moved HEAD" actual &&
+       test_cmp_rev base HEAD
+'
+
 test_expect_success 'cherry-pick --abort to cancel multiple revert' '
        pristine_detach anotherpick &&
        test_expect_code 1 git revert base..picked &&
@@ -210,7 +220,7 @@ test_expect_success 'cherry-pick still writes sequencer state when one commit is
        {
                git rev-list HEAD |
                git diff-tree --root --stdin |
-               sed "s/$_x40/OBJID/g"
+               sed "s/$OID_REGEX/OBJID/g"
        } >actual &&
        cat >expect <<-\EOF &&
        OBJID
@@ -237,9 +247,9 @@ test_expect_success '--abort after last commit in sequence' '
 test_expect_success 'cherry-pick does not implicitly stomp an existing operation' '
        pristine_detach initial &&
        test_expect_code 1 git cherry-pick base..anotherpick &&
-       test-chmtime -v +0 .git/sequencer >expect &&
+       test-tool chmtime --get .git/sequencer >expect &&
        test_expect_code 128 git cherry-pick unrelatedpick &&
-       test-chmtime -v +0 .git/sequencer >actual &&
+       test-tool chmtime --get .git/sequencer >actual &&
        test_cmp expect actual
 '
 
@@ -307,7 +317,7 @@ test_expect_success '--continue after resolving conflicts' '
        {
                git rev-list HEAD |
                git diff-tree --root --stdin |
-               sed "s/$_x40/OBJID/g"
+               sed "s/$OID_REGEX/OBJID/g"
        } >actual.log &&
        test_cmp expect foo &&
        test_cmp expect.log actual.log
@@ -324,7 +334,7 @@ test_expect_success '--continue after resolving conflicts and committing' '
        {
                git rev-list HEAD |
                git diff-tree --root --stdin |
-               sed "s/$_x40/OBJID/g"
+               sed "s/$OID_REGEX/OBJID/g"
        } >actual &&
        cat >expect <<-\EOF &&
        OBJID
@@ -375,7 +385,7 @@ test_expect_success '--continue respects opts' '
        git cat-file commit HEAD~1 >picked_msg &&
        git cat-file commit HEAD~2 >unrelatedpick_msg &&
        git cat-file commit HEAD~3 >initial_msg &&
-       test_must_fail grep "cherry picked from" initial_msg &&
+       ! grep "cherry picked from" initial_msg &&
        grep "cherry picked from" unrelatedpick_msg &&
        grep "cherry picked from" picked_msg &&
        grep "cherry picked from" anotherpick_msg
@@ -416,9 +426,9 @@ test_expect_failure '--signoff is automatically propagated to resolved conflict'
        git cat-file commit HEAD~1 >picked_msg &&
        git cat-file commit HEAD~2 >unrelatedpick_msg &&
        git cat-file commit HEAD~3 >initial_msg &&
-       test_must_fail grep "Signed-off-by:" initial_msg &&
+       ! grep "Signed-off-by:" initial_msg &&
        grep "Signed-off-by:" unrelatedpick_msg &&
-       test_must_fail grep "Signed-off-by:" picked_msg &&
+       ! grep "Signed-off-by:" picked_msg &&
        grep "Signed-off-by:" anotherpick_msg
 '