Add missing functions to contrib/emacs/vc-git.el
[gitweb.git] / t / t3404-rebase-interactive.sh
index 48aa8ea814001afd06d4d80b15dad15cb9e17aca..43a6675caa3a57c0ad5a2b177d8b437e660525af 100755 (executable)
@@ -63,7 +63,10 @@ test_expect_success 'setup' '
 
 cat > fake-editor.sh << EOF
 #!/bin/sh
-test "\$1" = .git/COMMIT_EDITMSG && exit
+test "\$1" = .git/COMMIT_EDITMSG && {
+       test -z "\$FAKE_COMMIT_MESSAGE" || echo "\$FAKE_COMMIT_MESSAGE" > "\$1"
+       exit
+}
 test -z "\$FAKE_LINES" && exit
 grep -v "^#" < "\$1" > "\$1".tmp
 rm "\$1"
@@ -99,6 +102,10 @@ test_expect_success 'rebase on top of a non-conflicting commit' '
        test $(git rev-parse I) = $(git rev-parse HEAD~2)
 '
 
+test_expect_success 'reflog for the branch shows state before rebase' '
+       test $(git rev-parse branch1@{1}) = $(git rev-parse original-branch1)
+'
+
 test_expect_success 'exchange two commits' '
        FAKE_LINES="2 1" git rebase -i HEAD~2 &&
        test H = $(git cat-file commit HEAD^ | tail -n 1) &&
@@ -140,6 +147,7 @@ test_expect_success 'abort' '
 test_expect_success 'retain authorship' '
        echo A > file7 &&
        git add file7 &&
+       test_tick &&
        GIT_AUTHOR_NAME="Twerp Snog" git commit -m "different author" &&
        git tag twerp &&
        git rebase -i --onto master HEAD^ &&
@@ -149,6 +157,7 @@ test_expect_success 'retain authorship' '
 test_expect_success 'squash' '
        git reset --hard twerp &&
        echo B > file7 &&
+       test_tick &&
        GIT_AUTHOR_NAME="Nitfol" git commit -m "nitfol" file7 &&
        echo "******************************" &&
        FAKE_LINES="1 squash 2" git rebase -i --onto master HEAD~2 &&
@@ -160,4 +169,47 @@ test_expect_success 'retain authorship when squashing' '
        git show HEAD | grep "^Author: Nitfol"
 '
 
+test_expect_success 'preserve merges with -p' '
+       git checkout -b to-be-preserved master^ &&
+       : > unrelated-file &&
+       git add unrelated-file &&
+       test_tick &&
+       git commit -m "unrelated" &&
+       git checkout -b to-be-rebased master &&
+       echo B > file1 &&
+       test_tick &&
+       git commit -m J file1 &&
+       test_tick &&
+       git merge to-be-preserved &&
+       echo C > file1 &&
+       test_tick &&
+       git commit -m K file1 &&
+       test_tick &&
+       git rebase -i -p --onto branch1 master &&
+       test $(git rev-parse HEAD^^2) = $(git rev-parse to-be-preserved) &&
+       test $(git rev-parse HEAD~3) = $(git rev-parse branch1) &&
+       test $(git show HEAD:file1) = C &&
+       test $(git show HEAD~2:file1) = B
+'
+
+test_expect_success '--continue tries to commit' '
+       test_tick &&
+       ! git rebase -i --onto new-branch1 HEAD^ &&
+       echo resolved > file1 &&
+       git add file1 &&
+       FAKE_COMMIT_MESSAGE="chouette!" git rebase --continue &&
+       test $(git rev-parse HEAD^) = $(git rev-parse new-branch1) &&
+       git show HEAD | grep chouette
+'
+
+test_expect_success 'verbose flag is heeded, even after --continue' '
+       git reset --hard HEAD@{1} &&
+       test_tick &&
+       ! git rebase -v -i --onto new-branch1 HEAD^ &&
+       echo resolved > file1 &&
+       git add file1 &&
+       git rebase --continue > output &&
+       grep "^ file1 |    2 +-$" output
+'
+
 test_done