Merge branch 'ph/rebase-preserve-all-merges'
[gitweb.git] / t / t3404-rebase-interactive.sh
index 68d61480fbeee024ca463ca0d5771bdfdf980866..8462be1db6a0fe4f9e28cd1662be604196141055 100755 (executable)
@@ -29,12 +29,6 @@ Initial setup:
 
 . "$TEST_DIRECTORY"/lib-rebase.sh
 
-test_cmp_rev () {
-       git rev-parse --verify "$1" >expect.rev &&
-       git rev-parse --verify "$2" >actual.rev &&
-       test_cmp expect.rev actual.rev
-}
-
 set_fake_editor
 
 # WARNING: Modifications to the initial repository can change the SHA ID used
@@ -118,6 +112,17 @@ test_expect_success 'rebase -i with the exec command checks tree cleanness' '
        git rebase --continue
 '
 
+test_expect_success 'rebase -i with exec of inexistent command' '
+       git checkout master &&
+       test_when_finished "git rebase --abort" &&
+       (
+       FAKE_LINES="exec_this-command-does-not-exist 1" &&
+       export FAKE_LINES &&
+       test_must_fail git rebase -i HEAD^ >actual 2>&1
+       ) &&
+       ! grep "Maybe git-rebase is broken" actual
+'
+
 test_expect_success 'no changes are a nop' '
        git checkout branch2 &&
        git rebase -i F &&
@@ -858,7 +863,7 @@ test_expect_success 'rebase -ix with --autosquash' '
 test_expect_success 'rebase --exec without -i shows error message' '
        git reset --hard execute &&
        test_must_fail git rebase --exec "git show HEAD" HEAD~2 2>actual &&
-       echo "--exec option must be used with --interactive option" >expected &&
+       echo "The --exec option must be used with the --interactive option" >expected &&
        test_i18ncmp expected actual
 '
 
@@ -872,4 +877,61 @@ test_expect_success 'rebase -i --exec without <CMD>' '
        git checkout master
 '
 
+test_expect_success 'rebase -i --root re-order and drop commits' '
+       git checkout E &&
+       FAKE_LINES="3 1 2 5" git rebase -i --root &&
+       test E = $(git cat-file commit HEAD | sed -ne \$p) &&
+       test B = $(git cat-file commit HEAD^ | sed -ne \$p) &&
+       test A = $(git cat-file commit HEAD^^ | sed -ne \$p) &&
+       test C = $(git cat-file commit HEAD^^^ | sed -ne \$p) &&
+       test 0 = $(git cat-file commit HEAD^^^ | grep -c ^parent\ )
+'
+
+test_expect_success 'rebase -i --root retain root commit author and message' '
+       git checkout A &&
+       echo B >file7 &&
+       git add file7 &&
+       GIT_AUTHOR_NAME="Twerp Snog" git commit -m "different author" &&
+       FAKE_LINES="2" git rebase -i --root &&
+       git cat-file commit HEAD | grep -q "^author Twerp Snog" &&
+       git cat-file commit HEAD | grep -q "^different author$"
+'
+
+test_expect_success 'rebase -i --root temporary sentinel commit' '
+       git checkout B &&
+       (
+               FAKE_LINES="2" &&
+               export FAKE_LINES &&
+               test_must_fail git rebase -i --root
+       ) &&
+       git cat-file commit HEAD | grep "^tree 4b825dc642cb" &&
+       git rebase --abort
+'
+
+test_expect_success 'rebase -i --root fixup root commit' '
+       git checkout B &&
+       FAKE_LINES="1 fixup 2" git rebase -i --root &&
+       test A = $(git cat-file commit HEAD | sed -ne \$p) &&
+       test B = $(git show HEAD:file1) &&
+       test 0 = $(git cat-file commit HEAD | grep -c ^parent\ )
+'
+
+test_expect_success 'rebase --edit-todo does not works on non-interactive rebase' '
+       git reset --hard &&
+       git checkout conflict-branch &&
+       test_must_fail git rebase --onto HEAD~2 HEAD~ &&
+       test_must_fail git rebase --edit-todo &&
+       git rebase --abort
+'
+
+test_expect_success 'rebase --edit-todo can be used to modify todo' '
+       git reset --hard &&
+       git checkout no-conflict-branch^0 &&
+       FAKE_LINES="edit 1 2 3" git rebase -i HEAD~3 &&
+       FAKE_LINES="2 1" git rebase --edit-todo &&
+       git rebase --continue
+       test M = $(git cat-file commit HEAD^ | sed -ne \$p) &&
+       test L = $(git cat-file commit HEAD | sed -ne \$p)
+'
+
 test_done