t3404: add test case for abbreviated commands
[gitweb.git] / t / t3404-rebase-interactive.sh
index 3704dbb2ecf6046e09adb03b451e4e531509b2f4..481a3500900d0fccb28762ba24b2ca422956a44f 100755 (executable)
@@ -108,6 +108,17 @@ test_expect_success 'rebase -i with the exec command runs from tree root' '
        rm -fr subdir
 '
 
+test_expect_success 'rebase -i with exec allows git commands in subdirs' '
+       test_when_finished "rm -rf subdir" &&
+       test_when_finished "git rebase --abort ||:" &&
+       git checkout master &&
+       mkdir subdir && (cd subdir &&
+       set_fake_editor &&
+       FAKE_LINES="1 exec_cd_subdir_&&_git_rev-parse_--is-inside-work-tree" \
+               git rebase -i HEAD^
+       )
+'
+
 test_expect_success 'rebase -i with the exec command checks tree cleanness' '
        git checkout master &&
        set_fake_editor &&
@@ -1249,6 +1260,28 @@ test_expect_success 'rebase -i respects rebase.missingCommitsCheck = error' '
        test B = $(git cat-file commit HEAD^ | sed -ne \$p)
 '
 
+test_expect_success 'respects rebase.abbreviateCommands with fixup, squash and exec' '
+       rebase_setup_and_clean abbrevcmd &&
+       test_commit "first" file1.txt "first line" first &&
+       test_commit "second" file1.txt "another line" second &&
+       test_commit "fixup! first" file2.txt "first line again" first_fixup &&
+       test_commit "squash! second" file1.txt "another line here" second_squash &&
+       cat >expected <<-EOF &&
+       p $(git rev-list --abbrev-commit -1 first) first
+       f $(git rev-list --abbrev-commit -1 first_fixup) fixup! first
+       x git show HEAD
+       p $(git rev-list --abbrev-commit -1 second) second
+       s $(git rev-list --abbrev-commit -1 second_squash) squash! second
+       x git show HEAD
+       EOF
+       git checkout abbrevcmd &&
+       set_cat_todo_editor &&
+       test_config rebase.abbreviateCommands true &&
+       test_must_fail git rebase -i --exec "git show HEAD" \
+               --autosquash master >actual &&
+       test_cmp expected actual
+'
+
 test_expect_success 'static check of bad command' '
        rebase_setup_and_clean bad-cmd &&
        set_fake_editor &&