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