]>
Commit | Line | Data |
---|---|---|
3ebfe63a MH |
1 | #!/bin/sh |
2 | ||
3 | test_description='git rebase --abort tests' | |
4 | ||
d1c02d93 | 5 | GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main |
334afbc7 JS |
6 | export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME |
7 | ||
3ebfe63a MH |
8 | . ./test-lib.sh |
9 | ||
97b88dd5 BD |
10 | ### Test that we handle space characters properly |
11 | work_dir="$(pwd)/test dir" | |
12 | ||
3ebfe63a | 13 | test_expect_success setup ' |
97b88dd5 BD |
14 | mkdir -p "$work_dir" && |
15 | cd "$work_dir" && | |
16 | git init && | |
3ebfe63a MH |
17 | echo a > a && |
18 | git add a && | |
19 | git commit -m a && | |
20 | git branch to-rebase && | |
21 | ||
22 | echo b > a && | |
23 | git commit -a -m b && | |
24 | echo c > a && | |
25 | git commit -a -m c && | |
26 | ||
27 | git checkout to-rebase && | |
28 | echo d > a && | |
29 | git commit -a -m "merge should fail on this" && | |
30 | echo e > a && | |
31 | git commit -a -m "merge should fail on this, too" && | |
32 | git branch pre-rebase | |
33 | ' | |
34 | ||
4947cf9c MH |
35 | testrebase() { |
36 | type=$1 | |
37 | dotest=$2 | |
3ebfe63a | 38 | |
4947cf9c | 39 | test_expect_success "rebase$type --abort" ' |
97b88dd5 | 40 | cd "$work_dir" && |
4947cf9c | 41 | # Clean up the state from the previous one |
97b88dd5 | 42 | git reset --hard pre-rebase && |
d1c02d93 | 43 | test_must_fail git rebase$type main && |
2caf20c5 | 44 | test_path_is_dir "$dotest" && |
4947cf9c MH |
45 | git rebase --abort && |
46 | test $(git rev-parse to-rebase) = $(git rev-parse pre-rebase) && | |
97b88dd5 | 47 | test ! -d "$dotest" |
4947cf9c | 48 | ' |
3ebfe63a | 49 | |
4947cf9c | 50 | test_expect_success "rebase$type --abort after --skip" ' |
97b88dd5 | 51 | cd "$work_dir" && |
4947cf9c | 52 | # Clean up the state from the previous one |
97b88dd5 | 53 | git reset --hard pre-rebase && |
d1c02d93 | 54 | test_must_fail git rebase$type main && |
2caf20c5 | 55 | test_path_is_dir "$dotest" && |
4947cf9c | 56 | test_must_fail git rebase --skip && |
d1c02d93 | 57 | test $(git rev-parse HEAD) = $(git rev-parse main) && |
0cb0e143 | 58 | git rebase --abort && |
4947cf9c | 59 | test $(git rev-parse to-rebase) = $(git rev-parse pre-rebase) && |
97b88dd5 | 60 | test ! -d "$dotest" |
4947cf9c | 61 | ' |
3ebfe63a | 62 | |
4947cf9c | 63 | test_expect_success "rebase$type --abort after --continue" ' |
97b88dd5 | 64 | cd "$work_dir" && |
4947cf9c | 65 | # Clean up the state from the previous one |
97b88dd5 | 66 | git reset --hard pre-rebase && |
d1c02d93 | 67 | test_must_fail git rebase$type main && |
2caf20c5 | 68 | test_path_is_dir "$dotest" && |
4947cf9c MH |
69 | echo c > a && |
70 | echo d >> a && | |
71 | git add a && | |
72 | test_must_fail git rebase --continue && | |
d1c02d93 | 73 | test $(git rev-parse HEAD) != $(git rev-parse main) && |
4947cf9c MH |
74 | git rebase --abort && |
75 | test $(git rev-parse to-rebase) = $(git rev-parse pre-rebase) && | |
97b88dd5 | 76 | test ! -d "$dotest" |
4947cf9c | 77 | ' |
729ec9e2 MZ |
78 | |
79 | test_expect_success "rebase$type --abort does not update reflog" ' | |
80 | cd "$work_dir" && | |
81 | # Clean up the state from the previous one | |
82 | git reset --hard pre-rebase && | |
83 | git reflog show to-rebase > reflog_before && | |
d1c02d93 | 84 | test_must_fail git rebase$type main && |
729ec9e2 MZ |
85 | git rebase --abort && |
86 | git reflog show to-rebase > reflog_after && | |
87 | test_cmp reflog_before reflog_after && | |
88 | rm reflog_before reflog_after | |
89 | ' | |
95135b06 MZ |
90 | |
91 | test_expect_success 'rebase --abort can not be used with other options' ' | |
92 | cd "$work_dir" && | |
93 | # Clean up the state from the previous one | |
94 | git reset --hard pre-rebase && | |
d1c02d93 | 95 | test_must_fail git rebase$type main && |
95135b06 MZ |
96 | test_must_fail git rebase -v --abort && |
97 | test_must_fail git rebase --abort -v && | |
98 | git rebase --abort | |
99 | ' | |
4947cf9c | 100 | } |
3ebfe63a | 101 | |
10cdb9f3 | 102 | testrebase " --apply" .git/rebase-apply |
28ed6e7b | 103 | testrebase " --merge" .git/rebase-merge |
3ebfe63a | 104 | |
10cdb9f3 | 105 | test_expect_success 'rebase --apply --quit' ' |
9512177b NTND |
106 | cd "$work_dir" && |
107 | # Clean up the state from the previous one | |
108 | git reset --hard pre-rebase && | |
d1c02d93 | 109 | test_must_fail git rebase --apply main && |
9512177b NTND |
110 | test_path_is_dir .git/rebase-apply && |
111 | head_before=$(git rev-parse HEAD) && | |
112 | git rebase --quit && | |
113 | test $(git rev-parse HEAD) = $head_before && | |
114 | test ! -d .git/rebase-apply | |
115 | ' | |
116 | ||
117 | test_expect_success 'rebase --merge --quit' ' | |
118 | cd "$work_dir" && | |
119 | # Clean up the state from the previous one | |
120 | git reset --hard pre-rebase && | |
d1c02d93 | 121 | test_must_fail git rebase --merge main && |
9512177b NTND |
122 | test_path_is_dir .git/rebase-merge && |
123 | head_before=$(git rev-parse HEAD) && | |
124 | git rebase --quit && | |
125 | test $(git rev-parse HEAD) = $head_before && | |
126 | test ! -d .git/rebase-merge | |
127 | ' | |
128 | ||
3ebfe63a | 129 | test_done |