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 that we handle space characters properly
11 work_dir="$(pwd)/test dir"
13 test_expect_success setup '
14 mkdir -p "$work_dir" &&
20 git branch to-rebase &&
27 git checkout to-rebase &&
29 git commit -a -m "merge should fail on this" &&
31 git commit -a -m "merge should fail on this, too" &&
39 test_expect_success "rebase$type --abort" '
41 # Clean up the state from the previous one
42 git reset --hard pre-rebase &&
43 test_must_fail git rebase$type main &&
44 test_path_is_dir "$dotest" &&
46 test $(git rev-parse to-rebase) = $(git rev-parse pre-rebase) &&
50 test_expect_success "rebase$type --abort after --skip" '
52 # Clean up the state from the previous one
53 git reset --hard pre-rebase &&
54 test_must_fail git rebase$type main &&
55 test_path_is_dir "$dotest" &&
56 test_must_fail git rebase --skip &&
57 test $(git rev-parse HEAD) = $(git rev-parse main) &&
59 test $(git rev-parse to-rebase) = $(git rev-parse pre-rebase) &&
63 test_expect_success "rebase$type --abort after --continue" '
65 # Clean up the state from the previous one
66 git reset --hard pre-rebase &&
67 test_must_fail git rebase$type main &&
68 test_path_is_dir "$dotest" &&
72 test_must_fail git rebase --continue &&
73 test $(git rev-parse HEAD) != $(git rev-parse main) &&
75 test $(git rev-parse to-rebase) = $(git rev-parse pre-rebase) &&
79 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' '
93 # Clean up the state from the previous one
94 git reset --hard pre-rebase &&
95 test_must_fail git rebase$type main &&
96 test_must_fail git rebase -v --abort &&
97 test_must_fail git rebase --abort -v &&
102 testrebase " --apply" .git/rebase-apply
103 testrebase " --merge" .git/rebase-merge
105 test_expect_success 'rebase --apply --quit' '
107 # Clean up the state from the previous one
108 git reset --hard pre-rebase &&
109 test_must_fail git rebase --apply main &&
110 test_path_is_dir .git/rebase-apply &&
111 head_before=$(git rev-parse HEAD) &&
113 test $(git rev-parse HEAD) = $head_before &&
114 test ! -d .git/rebase-apply
117 test_expect_success 'rebase --merge --quit' '
119 # Clean up the state from the previous one
120 git reset --hard pre-rebase &&
121 test_must_fail git rebase --merge main &&
122 test_path_is_dir .git/rebase-merge &&
123 head_before=$(git rev-parse HEAD) &&
125 test $(git rev-parse HEAD) = $head_before &&
126 test ! -d .git/rebase-merge