]> git.ipfire.org Git - thirdparty/git.git/blobdiff - t/t3404-rebase-interactive.sh
use build-time SHELL_PATH in test scripts
[thirdparty/git.git] / t / t3404-rebase-interactive.sh
index f1039d1a2146ed68217d849d7588d9ca65af785b..049aa375381b5929d1f35b7316c3fe6a647e4f93 100755 (executable)
@@ -61,8 +61,8 @@ test_expect_success 'setup' '
        git tag I
 '
 
-cat > fake-editor.sh <<\EOF
-#!/bin/sh
+echo "#!$SHELL_PATH" >fake-editor.sh
+cat >> fake-editor.sh <<\EOF
 case "$1" in
 */COMMIT_EDITMSG)
        test -z "$FAKE_COMMIT_MESSAGE" || echo "$FAKE_COMMIT_MESSAGE" > "$1"
@@ -149,7 +149,8 @@ test_expect_success 'stop on conflicting pick' '
        diff -u expect .git/.dotest-merge/patch &&
        diff -u expect2 file1 &&
        test 4 = $(grep -v "^#" < .git/.dotest-merge/done | wc -l) &&
-       test 0 = $(grep -v "^#" < .git/.dotest-merge/git-rebase-todo | wc -l)
+       test 0 = $(grep -ve "^#" -e "^$" < .git/.dotest-merge/git-rebase-todo |
+               wc -l)
 '
 
 test_expect_success 'abort' '
@@ -183,6 +184,12 @@ test_expect_success 'retain authorship when squashing' '
        git show HEAD | grep "^Author: Twerp Snog"
 '
 
+test_expect_success '-p handles "no changes" gracefully' '
+       HEAD=$(git rev-parse HEAD) &&
+       git rebase -i -p HEAD^ &&
+       test $HEAD = $(git rev-parse HEAD)
+'
+
 test_expect_success 'preserve merges with -p' '
        git checkout -b to-be-preserved master^ &&
        : > unrelated-file &&
@@ -317,4 +324,42 @@ test_expect_success 'rebase a detached HEAD' '
        test $grandparent = $(git rev-parse HEAD~2)
 '
 
+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 &&
+       echo "monde! " >> file1 &&
+       test_tick &&
+       ! git commit -m doesnt-verify file1 &&
+       git commit -m doesnt-verify --no-verify file1 &&
+       test_tick &&
+       FAKE_LINES=2 git rebase -i HEAD~2
+
+'
+
+test_expect_success 'rebase with a file named HEAD in worktree' '
+
+       rm -fr .git/hooks &&
+       git reset --hard &&
+       git checkout -b branch3 A &&
+
+       (
+               GIT_AUTHOR_NAME="Squashed Away" &&
+               export GIT_AUTHOR_NAME &&
+               >HEAD &&
+               git add HEAD &&
+               git commit -m "Add head" &&
+               >BODY &&
+               git add BODY &&
+               git commit -m "Add body"
+       ) &&
+
+       FAKE_LINES="1 squash 2" git rebase -i to-be-rebased &&
+       test "$(git show -s --pretty=format:%an)" = "Squashed Away"
+
+'
+
 test_done