]>
Commit | Line | Data |
---|---|---|
25e93250 DK |
1 | #!/bin/sh |
2 | ||
3 | test_description='git rebase --continue tests' | |
4 | ||
5 | . ./test-lib.sh | |
6 | ||
7 | . "$TEST_DIRECTORY"/lib-rebase.sh | |
8 | ||
9 | set_fake_editor | |
10 | ||
11 | test_expect_success 'setup' ' | |
12 | test_commit "commit-new-file-F1" F1 1 && | |
13 | test_commit "commit-new-file-F2" F2 2 && | |
14 | ||
15 | git checkout -b topic HEAD^ && | |
16 | test_commit "commit-new-file-F2-on-topic-branch" F2 22 && | |
17 | ||
18 | git checkout master | |
19 | ' | |
20 | ||
21 | test_expect_success 'interactive rebase --continue works with touched file' ' | |
22 | rm -fr .git/rebase-* && | |
23 | git reset --hard && | |
24 | git checkout master && | |
25 | ||
26 | FAKE_LINES="edit 1" git rebase -i HEAD^ && | |
27 | test-chmtime =-60 F1 && | |
28 | git rebase --continue | |
29 | ' | |
30 | ||
31 | test_expect_success 'non-interactive rebase --continue works with touched file' ' | |
32 | rm -fr .git/rebase-* && | |
33 | git reset --hard && | |
34 | git checkout master && | |
35 | ||
36 | test_must_fail git rebase --onto master master topic && | |
37 | echo "Resolved" >F2 && | |
38 | git add F2 && | |
39 | test-chmtime =-60 F1 && | |
40 | git rebase --continue | |
41 | ' | |
42 | ||
95135b06 MZ |
43 | test_expect_success 'rebase --continue can not be used with other options' ' |
44 | test_must_fail git rebase -v --continue && | |
45 | test_must_fail git rebase --continue -v | |
46 | ' | |
47 | ||
80ff4795 MZ |
48 | test_expect_success 'rebase --continue remembers merge strategy and options' ' |
49 | rm -fr .git/rebase-* && | |
50 | git reset --hard commit-new-file-F2-on-topic-branch && | |
51 | test_commit "commit-new-file-F3-on-topic-branch" F3 32 && | |
52 | test_when_finished "rm -fr test-bin funny.was.run" && | |
53 | mkdir test-bin && | |
02380389 | 54 | cat >test-bin/git-merge-funny <<-EOF && |
80ff4795 MZ |
55 | #!$SHELL_PATH |
56 | case "\$1" in --opt) ;; *) exit 2 ;; esac | |
57 | shift && | |
58 | >funny.was.run && | |
59 | exec git merge-recursive "\$@" | |
60 | EOF | |
61 | chmod +x test-bin/git-merge-funny && | |
62 | ( | |
63 | PATH=./test-bin:$PATH | |
64 | test_must_fail git rebase -s funny -Xopt master topic | |
65 | ) && | |
66 | test -f funny.was.run && | |
67 | rm funny.was.run && | |
68 | echo "Resolved" >F2 && | |
69 | git add F2 && | |
70 | ( | |
71 | PATH=./test-bin:$PATH | |
72 | git rebase --continue | |
73 | ) && | |
74 | test -f funny.was.run | |
75 | ' | |
dd6fb005 | 76 | |
a5a959d9 EN |
77 | test_expect_failure 'rebase -i --continue handles merge strategy and options' ' |
78 | rm -fr .git/rebase-* && | |
79 | git reset --hard commit-new-file-F2-on-topic-branch && | |
80 | test_commit "commit-new-file-F3-on-topic-branch-for-dash-i" F3 32 && | |
81 | test_when_finished "rm -fr test-bin funny.was.run funny.args" && | |
82 | mkdir test-bin && | |
83 | cat >test-bin/git-merge-funny <<-EOF && | |
84 | #!$SHELL_PATH | |
85 | echo "\$@" >>funny.args | |
86 | case "\$1" in --opt) ;; *) exit 2 ;; esac | |
87 | case "\$2" in --foo) ;; *) exit 2 ;; esac | |
88 | case "\$4" in --) ;; *) exit 2 ;; esac | |
89 | shift 2 && | |
90 | >funny.was.run && | |
91 | exec git merge-recursive "\$@" | |
92 | EOF | |
93 | chmod +x test-bin/git-merge-funny && | |
94 | ( | |
95 | PATH=./test-bin:$PATH && | |
96 | test_must_fail git rebase -i -s funny -Xopt -Xfoo master topic | |
97 | ) && | |
98 | test -f funny.was.run && | |
99 | rm funny.was.run && | |
100 | echo "Resolved" >F2 && | |
101 | git add F2 && | |
102 | ( | |
103 | PATH=./test-bin:$PATH && | |
104 | git rebase --continue | |
105 | ) && | |
106 | test -f funny.was.run | |
107 | ' | |
108 | ||
dd6fb005 JS |
109 | test_expect_success 'rebase passes merge strategy options correctly' ' |
110 | rm -fr .git/rebase-* && | |
111 | git reset --hard commit-new-file-F3-on-topic-branch && | |
112 | test_commit theirs-to-merge && | |
113 | git reset --hard HEAD^ && | |
114 | test_commit some-commit && | |
115 | test_tick && | |
116 | git merge --no-ff theirs-to-merge && | |
117 | FAKE_LINES="1 edit 2 3" git rebase -i -f -p -m \ | |
118 | -s recursive --strategy-option=theirs HEAD~2 && | |
119 | test_commit force-change && | |
120 | git rebase --continue | |
121 | ' | |
80ff4795 | 122 | |
5fb415b5 | 123 | test_expect_success 'setup rerere database' ' |
b3e4847e MZ |
124 | rm -fr .git/rebase-* && |
125 | git reset --hard commit-new-file-F3-on-topic-branch && | |
02380389 | 126 | git checkout master && |
b3e4847e | 127 | test_commit "commit-new-file-F3" F3 3 && |
5fb415b5 | 128 | test_config rerere.enabled true && |
b3e4847e MZ |
129 | test_must_fail git rebase -m master topic && |
130 | echo "Resolved" >F2 && | |
5fb415b5 | 131 | cp F2 expected-F2 && |
b3e4847e MZ |
132 | git add F2 && |
133 | test_must_fail git rebase --continue && | |
134 | echo "Resolved" >F3 && | |
5fb415b5 | 135 | cp F3 expected-F3 && |
b3e4847e MZ |
136 | git add F3 && |
137 | git rebase --continue && | |
5fb415b5 | 138 | git reset --hard topic@{1} |
b3e4847e MZ |
139 | ' |
140 | ||
5fb415b5 PW |
141 | prepare () { |
142 | rm -fr .git/rebase-* && | |
143 | git reset --hard commit-new-file-F3-on-topic-branch && | |
144 | git checkout master && | |
145 | test_config rerere.enabled true | |
146 | } | |
147 | ||
148 | test_rerere_autoupdate () { | |
149 | action=$1 && | |
150 | test_expect_success "rebase $action --continue remembers --rerere-autoupdate" ' | |
151 | prepare && | |
152 | test_must_fail git rebase $action --rerere-autoupdate master topic && | |
153 | test_cmp expected-F2 F2 && | |
154 | git diff-files --quiet && | |
155 | test_must_fail git rebase --continue && | |
156 | test_cmp expected-F3 F3 && | |
157 | git diff-files --quiet && | |
158 | git rebase --continue | |
159 | ' | |
160 | ||
161 | test_expect_success "rebase $action --continue honors rerere.autoUpdate" ' | |
162 | prepare && | |
163 | test_config rerere.autoupdate true && | |
164 | test_must_fail git rebase $action master topic && | |
165 | test_cmp expected-F2 F2 && | |
166 | git diff-files --quiet && | |
167 | test_must_fail git rebase --continue && | |
168 | test_cmp expected-F3 F3 && | |
169 | git diff-files --quiet && | |
170 | git rebase --continue | |
171 | ' | |
172 | ||
173 | test_expect_success "rebase $action --continue remembers --no-rerere-autoupdate" ' | |
174 | prepare && | |
175 | test_config rerere.autoupdate true && | |
176 | test_must_fail git rebase $action --no-rerere-autoupdate master topic && | |
177 | test_cmp expected-F2 F2 && | |
178 | test_must_fail git diff-files --quiet && | |
179 | git add F2 && | |
180 | test_must_fail git rebase --continue && | |
181 | test_cmp expected-F3 F3 && | |
182 | test_must_fail git diff-files --quiet && | |
183 | git add F3 && | |
184 | git rebase --continue | |
185 | ' | |
186 | } | |
187 | ||
188 | test_rerere_autoupdate | |
189 | test_rerere_autoupdate -m | |
9b6d7a62 PW |
190 | GIT_SEQUENCE_EDITOR=: && export GIT_SEQUENCE_EDITOR |
191 | test_rerere_autoupdate -i | |
192 | test_rerere_autoupdate --preserve-merges | |
5fb415b5 | 193 | |
25e93250 | 194 | test_done |