]> git.ipfire.org Git - thirdparty/git.git/blobdiff - t/t3404-rebase-interactive.sh
Merge branch 'ec/fetch-mark-common-refs-trace2'
[thirdparty/git.git] / t / t3404-rebase-interactive.sh
index c5d0326825af33cfe2eec327fb5d5f461bfc8aa2..bf0dc756d2e6ab5b8626c04d76f21d03fb712b28 100755 (executable)
@@ -29,9 +29,6 @@ Initial setup:
 
 . "$TEST_DIRECTORY"/lib-rebase.sh
 
-# WARNING: Modifications to the initial repository can change the SHA ID used
-# in the expect2 file for the 'stop on conflicting pick' test.
-
 test_expect_success 'setup' '
        test_commit A file1 &&
        test_commit B file1 &&
@@ -161,8 +158,6 @@ test_expect_success 'rebase -x with empty command fails' '
        test_i18ncmp expected actual
 '
 
-LF='
-'
 test_expect_success 'rebase -x with newline in command fails' '
        test_when_finished "git rebase --abort ||:" &&
        test_must_fail env git rebase -x "a${LF}b" @ 2>actual &&
@@ -239,25 +234,28 @@ test_expect_success 'exchange two commits' '
                FAKE_LINES="2 1" git rebase -i HEAD~2
        ) &&
        test H = $(git cat-file commit HEAD^ | sed -ne \$p) &&
-       test G = $(git cat-file commit HEAD | sed -ne \$p)
+       test G = $(git cat-file commit HEAD | sed -ne \$p) &&
+       blob1=$(git rev-parse --short HEAD^:file1) &&
+       blob2=$(git rev-parse --short HEAD:file1) &&
+       commit=$(git rev-parse --short HEAD)
 '
 
 test_expect_success 'stop on conflicting pick' '
-       cat >expect <<-\EOF &&
+       cat >expect <<-EOF &&
        diff --git a/file1 b/file1
-       index f70f10e..fd79235 100644
+       index $blob1..$blob2 100644
        --- a/file1
        +++ b/file1
        @@ -1 +1 @@
        -A
        +G
        EOF
-       cat >expect2 <<-\EOF &&
+       cat >expect2 <<-EOF &&
        <<<<<<< HEAD
        D
        =======
        G
-       >>>>>>> 5d18e54... G
+       >>>>>>> $commit... G
        EOF
        git tag new-branch1 &&
        test_must_fail git rebase -i master &&
@@ -1063,7 +1061,7 @@ test_expect_success 'rebase -i --root temporary sentinel commit' '
                set_fake_editor &&
                test_must_fail env FAKE_LINES="2" git rebase -i --root
        ) &&
-       git cat-file commit HEAD | grep "^tree 4b825dc642cb" &&
+       git cat-file commit HEAD | grep "^tree $EMPTY_TREE" &&
        git rebase --abort
 '
 
@@ -1139,7 +1137,7 @@ test_expect_success C_LOCALE_OUTPUT 'rebase --edit-todo does not work on non-int
        git checkout conflict-branch &&
        (
                set_fake_editor &&
-               test_must_fail git rebase --onto HEAD~2 HEAD~ &&
+               test_must_fail git rebase -f --onto HEAD~2 HEAD~ &&
                test_must_fail git rebase --edit-todo
        ) &&
        git rebase --abort
@@ -1251,7 +1249,7 @@ test_expect_success 'rebase -i error on commits with \ in message' '
        test_expect_code 1 grep  "      emp" error
 '
 
-test_expect_success 'short SHA-1 setup' '
+test_expect_success SHA1 'short SHA-1 setup' '
        test_when_finished "git checkout master" &&
        git checkout --orphan collide &&
        git rm -rf . &&
@@ -1263,7 +1261,7 @@ test_expect_success 'short SHA-1 setup' '
        )
 '
 
-test_expect_success 'short SHA-1 collide' '
+test_expect_success SHA1 'short SHA-1 collide' '
        test_when_finished "reset_rebase && git checkout master" &&
        git checkout collide &&
        (
@@ -1537,7 +1535,6 @@ test_expect_success 'editor saves as CR/LF' '
        )
 '
 
-SQ="'"
 test_expect_success 'rebase -i --gpg-sign=<key-id>' '
        test_when_finished "test_might_fail git rebase --abort" &&
        (
@@ -1583,6 +1580,25 @@ test_expect_success 'valid author header when author contains single quote' '
        test_cmp expected actual
 '
 
+test_expect_success 'post-commit hook is called' '
+       test_when_finished "rm -f .git/hooks/post-commit" &&
+       >actual &&
+       mkdir -p .git/hooks &&
+       write_script .git/hooks/post-commit <<-\EOS &&
+       git rev-parse HEAD >>actual
+       EOS
+       (
+               set_fake_editor &&
+               FAKE_LINES="edit 4 1 reword 2 fixup 3" git rebase -i A E &&
+               echo x>file3 &&
+               git add file3 &&
+               FAKE_COMMIT_MESSAGE=edited git rebase --continue
+       ) &&
+       git rev-parse HEAD@{5} HEAD@{4} HEAD@{3} HEAD@{2} HEAD@{1} HEAD \
+               >expect &&
+       test_cmp expect actual
+'
+
 # This must be the last test in this file
 test_expect_success '$EDITOR and friends are unchanged' '
        test_editor_unchanged