3 test_description
='git rebase --abort tests'
5 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
=main
6 export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
10 test_expect_success setup
'
12 git branch to-rebase &&
14 test_commit --annotate b a b &&
15 test_commit --annotate c a c &&
17 git checkout to-rebase &&
18 test_commit "merge should fail on this" a d d &&
19 test_commit --annotate "merge should fail on this, too" a e pre-rebase
22 # Check that HEAD is equal to "pre-rebase" and the current branch is
25 test_cmp_rev HEAD pre-rebase^
{commit
} &&
26 test "$(git symbolic-ref HEAD)" = refs
/heads
/to-rebase
33 test_expect_success
"rebase$type --abort" '
34 # Clean up the state from the previous one
35 git reset --hard pre-rebase &&
36 test_must_fail git rebase$type main &&
37 test_path_is_dir "$state_dir" &&
40 test_path_is_missing "$state_dir"
43 test_expect_success
"rebase$type --abort after --skip" '
44 # Clean up the state from the previous one
45 git reset --hard pre-rebase &&
46 test_must_fail git rebase$type main &&
47 test_path_is_dir "$state_dir" &&
48 test_must_fail git rebase --skip &&
49 test_cmp_rev HEAD main &&
52 test_path_is_missing "$state_dir"
55 test_expect_success
"rebase$type --abort after --continue" '
56 # Clean up the state from the previous one
57 git reset --hard pre-rebase &&
58 test_must_fail git rebase$type main &&
59 test_path_is_dir "$state_dir" &&
63 test_must_fail git rebase --continue &&
64 test_cmp_rev ! HEAD main &&
67 test_path_is_missing "$state_dir"
70 test_expect_success
"rebase$type --abort when checking out a tag" '
71 test_when_finished "git symbolic-ref HEAD refs/heads/to-rebase" &&
72 git reset --hard a -- &&
73 test_must_fail git rebase$type --onto b c pre-rebase &&
74 test_cmp_rev HEAD b^{commit} &&
76 test_cmp_rev HEAD pre-rebase^{commit} &&
77 ! git symbolic-ref HEAD
80 test_expect_success
"rebase$type --abort does not update reflog" '
81 # Clean up the state from the previous one
82 git reset --hard pre-rebase &&
83 git reflog show to-rebase > reflog_before &&
84 test_must_fail git rebase$type main &&
86 git reflog show to-rebase > reflog_after &&
87 test_cmp reflog_before reflog_after &&
88 rm reflog_before reflog_after
91 test_expect_success
'rebase --abort can not be used with other options' '
92 # Clean up the state from the previous one
93 git reset --hard pre-rebase &&
94 test_must_fail git rebase$type main &&
95 test_must_fail git rebase -v --abort &&
96 test_must_fail git rebase --abort -v &&
100 test_expect_success
"rebase$type --quit" '
101 test_when_finished "git symbolic-ref HEAD refs/heads/to-rebase" &&
102 # Clean up the state from the previous one
103 git reset --hard pre-rebase &&
104 test_must_fail git rebase$type main &&
105 test_path_is_dir $state_dir &&
106 head_before=$(git rev-parse HEAD) &&
108 test_cmp_rev HEAD $head_before &&
109 test_path_is_missing .git/rebase-apply
113 testrebase
" --apply" .git
/rebase-apply
114 testrebase
" --merge" .git
/rebase-merge