Merge branch 'tb/core-eol-fix' into maint
[gitweb.git] / t / t3404-rebase-interactive.sh
index 65474dc13aa1931757c6fae4721059f89c5655aa..d6d65a3a9435a456f8efad15b8c7c63db00a8e5f 100755 (executable)
@@ -555,10 +555,9 @@ test_expect_success 'rebase a detached HEAD' '
 test_expect_success 'rebase a commit violating pre-commit' '
 
        mkdir -p .git/hooks &&
-       PRE_COMMIT=.git/hooks/pre-commit &&
-       echo "#!/bin/sh" > $PRE_COMMIT &&
-       echo "test -z \"\$(git diff --cached --check)\"" >> $PRE_COMMIT &&
-       chmod a+x $PRE_COMMIT &&
+       write_script .git/hooks/pre-commit <<-\EOF &&
+       test -z "$(git diff --cached --check)"
+       EOF
        echo "monde! " >> file1 &&
        test_tick &&
        test_must_fail git commit -m doesnt-verify file1 &&
@@ -961,13 +960,13 @@ test_expect_success 'rebase -i produces readable reflog' '
        set_fake_editor &&
        git rebase -i --onto I F branch-reflog-test &&
        cat >expect <<-\EOF &&
-       rebase -i (start): checkout I
-       rebase -i (pick): G
-       rebase -i (pick): H
        rebase -i (finish): returning to refs/heads/branch-reflog-test
+       rebase -i (pick): H
+       rebase -i (pick): G
+       rebase -i (start): checkout I
        EOF
-       tail -n 4 .git/logs/HEAD |
-       sed -e "s/.*    //" >actual &&
+       git reflog -n4 HEAD |
+       sed "s/[^:]*: //" >actual &&
        test_cmp expect actual
 '
 
@@ -1006,6 +1005,22 @@ test_expect_success 'rebase -i with --strategy and -X' '
        test $(cat file1) = Z
 '
 
+test_expect_success 'interrupted rebase -i with --strategy and -X' '
+       git checkout -b conflict-merge-use-theirs-interrupted conflict-branch &&
+       git reset --hard HEAD^ &&
+       >breakpoint &&
+       git add breakpoint &&
+       git commit -m "breakpoint for interactive mode" &&
+       echo five >conflict &&
+       echo Z >file1 &&
+       git commit -a -m "one file conflict" &&
+       set_fake_editor &&
+       FAKE_LINES="edit 1 2" git rebase -i --strategy=recursive -Xours conflict-branch &&
+       git rebase --continue &&
+       test $(git show conflict-branch:conflict) = $(cat conflict) &&
+       test $(cat file1) = Z
+'
+
 test_expect_success 'rebase -i error on commits with \ in message' '
        current_head=$(git rev-parse HEAD) &&
        test_when_finished "git rebase --abort; git reset --hard $current_head; rm -f error" &&
@@ -1102,6 +1117,27 @@ test_expect_success 'rebase -i commits that overwrite untracked files (no ff)' '
        test $(git cat-file commit HEAD | sed -ne \$p) = I
 '
 
+test_expect_success 'rebase --continue removes CHERRY_PICK_HEAD' '
+       git checkout -b commit-to-skip &&
+       for double in X 3 1
+       do
+               test_seq 5 | sed "s/$double/&&/" >seq &&
+               git add seq &&
+               test_tick &&
+               git commit -m seq-$double
+       done &&
+       git tag seq-onto &&
+       git reset --hard HEAD~2 &&
+       git cherry-pick seq-onto &&
+       set_fake_editor &&
+       test_must_fail env FAKE_LINES= git rebase -i seq-onto &&
+       test -d .git/rebase-merge &&
+       git rebase --continue &&
+       git diff --exit-code seq-onto &&
+       test ! -d .git/rebase-merge &&
+       test ! -f .git/CHERRY_PICK_HEAD
+'
+
 rebase_setup_and_clean () {
        test_when_finished "
                git checkout master &&
@@ -1213,7 +1249,7 @@ test_expect_success 'tabs and spaces are accepted in the todolist' '
                # Turn single spaces into space/tab mix
                sed "1s/ /      /g; 2s/ /  /g; 3s/ /    /g" "$1"
                printf "\n\t# comment\n #more\n\t # comment\n"
-       ) >$1.new
+       ) >"$1.new"
        mv "$1.new" "$1"
        EOF
        test_set_editor "$(pwd)/add-indent.sh" &&
@@ -1240,7 +1276,7 @@ test_expect_success 'static check of bad SHA-1' '
        test E = $(git cat-file commit HEAD | sed -ne \$p)
 '
 
-test_expect_failure 'editor saves as CR/LF' '
+test_expect_success 'editor saves as CR/LF' '
        git checkout -b with-crlf &&
        write_script add-crs.sh <<-\EOF &&
        sed -e "s/\$/Q/" <"$1" | tr Q "\\015" >"$1".new &&