Blame


1 818c7501 2019-07-11 stsp #!/bin/sh
2 818c7501 2019-07-11 stsp #
3 818c7501 2019-07-11 stsp # Copyright (c) 2019 Stefan Sperling <stsp@openbsd.org>
4 818c7501 2019-07-11 stsp #
5 818c7501 2019-07-11 stsp # Permission to use, copy, modify, and distribute this software for any
6 818c7501 2019-07-11 stsp # purpose with or without fee is hereby granted, provided that the above
7 818c7501 2019-07-11 stsp # copyright notice and this permission notice appear in all copies.
8 818c7501 2019-07-11 stsp #
9 818c7501 2019-07-11 stsp # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 818c7501 2019-07-11 stsp # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 818c7501 2019-07-11 stsp # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 818c7501 2019-07-11 stsp # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 818c7501 2019-07-11 stsp # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 818c7501 2019-07-11 stsp # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 818c7501 2019-07-11 stsp # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16 818c7501 2019-07-11 stsp
17 818c7501 2019-07-11 stsp . ./common.sh
18 818c7501 2019-07-11 stsp
19 818c7501 2019-07-11 stsp function test_rebase_basic {
20 818c7501 2019-07-11 stsp local testroot=`test_init rebase_basic`
21 818c7501 2019-07-11 stsp
22 818c7501 2019-07-11 stsp (cd $testroot/repo && git checkout -q -b newbranch)
23 818c7501 2019-07-11 stsp echo "modified delta on branch" > $testroot/repo/gamma/delta
24 818c7501 2019-07-11 stsp git_commit $testroot/repo -m "committing to delta on newbranch"
25 818c7501 2019-07-11 stsp
26 818c7501 2019-07-11 stsp echo "modified alpha on branch" > $testroot/repo/alpha
27 818c7501 2019-07-11 stsp (cd $testroot/repo && git rm -q beta)
28 818c7501 2019-07-11 stsp echo "new file on branch" > $testroot/repo/epsilon/new
29 818c7501 2019-07-11 stsp (cd $testroot/repo && git add epsilon/new)
30 818c7501 2019-07-11 stsp git_commit $testroot/repo -m "committing more changes on newbranch"
31 818c7501 2019-07-11 stsp
32 818c7501 2019-07-11 stsp local orig_commit1=`git_show_parent_commit $testroot/repo`
33 818c7501 2019-07-11 stsp local orig_commit2=`git_show_head $testroot/repo`
34 818c7501 2019-07-11 stsp
35 818c7501 2019-07-11 stsp (cd $testroot/repo && git checkout -q master)
36 818c7501 2019-07-11 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
37 818c7501 2019-07-11 stsp git_commit $testroot/repo -m "committing to zeta on master"
38 818c7501 2019-07-11 stsp local master_commit=`git_show_head $testroot/repo`
39 818c7501 2019-07-11 stsp
40 818c7501 2019-07-11 stsp got checkout $testroot/repo $testroot/wt > /dev/null
41 818c7501 2019-07-11 stsp ret="$?"
42 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
43 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
44 818c7501 2019-07-11 stsp return 1
45 818c7501 2019-07-11 stsp fi
46 818c7501 2019-07-11 stsp
47 818c7501 2019-07-11 stsp (cd $testroot/wt && got rebase newbranch > $testroot/stdout)
48 818c7501 2019-07-11 stsp
49 818c7501 2019-07-11 stsp (cd $testroot/repo && git checkout -q newbranch)
50 818c7501 2019-07-11 stsp local new_commit1=`git_show_parent_commit $testroot/repo`
51 818c7501 2019-07-11 stsp local new_commit2=`git_show_head $testroot/repo`
52 818c7501 2019-07-11 stsp
53 818c7501 2019-07-11 stsp local short_orig_commit1=`trim_obj_id 28 $orig_commit1`
54 818c7501 2019-07-11 stsp local short_orig_commit2=`trim_obj_id 28 $orig_commit2`
55 818c7501 2019-07-11 stsp local short_new_commit1=`trim_obj_id 28 $new_commit1`
56 818c7501 2019-07-11 stsp local short_new_commit2=`trim_obj_id 28 $new_commit2`
57 818c7501 2019-07-11 stsp
58 818c7501 2019-07-11 stsp echo "G gamma/delta" >> $testroot/stdout.expected
59 818c7501 2019-07-11 stsp echo -n "$short_orig_commit1 -> $short_new_commit1" \
60 818c7501 2019-07-11 stsp >> $testroot/stdout.expected
61 818c7501 2019-07-11 stsp echo ": committing to delta on newbranch" >> $testroot/stdout.expected
62 818c7501 2019-07-11 stsp echo "G alpha" >> $testroot/stdout.expected
63 818c7501 2019-07-11 stsp echo "D beta" >> $testroot/stdout.expected
64 818c7501 2019-07-11 stsp echo "A epsilon/new" >> $testroot/stdout.expected
65 818c7501 2019-07-11 stsp echo -n "$short_orig_commit2 -> $short_new_commit2" \
66 818c7501 2019-07-11 stsp >> $testroot/stdout.expected
67 818c7501 2019-07-11 stsp echo ": committing more changes on newbranch" \
68 818c7501 2019-07-11 stsp >> $testroot/stdout.expected
69 818c7501 2019-07-11 stsp echo "Switching work tree to refs/heads/newbranch" \
70 818c7501 2019-07-11 stsp >> $testroot/stdout.expected
71 818c7501 2019-07-11 stsp
72 818c7501 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
73 818c7501 2019-07-11 stsp ret="$?"
74 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
75 818c7501 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
76 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
77 818c7501 2019-07-11 stsp return 1
78 818c7501 2019-07-11 stsp fi
79 818c7501 2019-07-11 stsp
80 818c7501 2019-07-11 stsp echo "modified delta on branch" > $testroot/content.expected
81 818c7501 2019-07-11 stsp cat $testroot/wt/gamma/delta > $testroot/content
82 818c7501 2019-07-11 stsp cmp -s $testroot/content.expected $testroot/content
83 818c7501 2019-07-11 stsp ret="$?"
84 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
85 818c7501 2019-07-11 stsp diff -u $testroot/content.expected $testroot/content
86 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
87 818c7501 2019-07-11 stsp return 1
88 818c7501 2019-07-11 stsp fi
89 818c7501 2019-07-11 stsp
90 818c7501 2019-07-11 stsp echo "modified alpha on branch" > $testroot/content.expected
91 818c7501 2019-07-11 stsp cat $testroot/wt/alpha > $testroot/content
92 818c7501 2019-07-11 stsp cmp -s $testroot/content.expected $testroot/content
93 818c7501 2019-07-11 stsp ret="$?"
94 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
95 818c7501 2019-07-11 stsp diff -u $testroot/content.expected $testroot/content
96 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
97 818c7501 2019-07-11 stsp return 1
98 818c7501 2019-07-11 stsp fi
99 818c7501 2019-07-11 stsp
100 818c7501 2019-07-11 stsp if [ -e $testroot/wt/beta ]; then
101 818c7501 2019-07-11 stsp echo "removed file beta still exists on disk" >&2
102 818c7501 2019-07-11 stsp test_done "$testroot" "1"
103 818c7501 2019-07-11 stsp return 1
104 818c7501 2019-07-11 stsp fi
105 818c7501 2019-07-11 stsp
106 818c7501 2019-07-11 stsp echo "new file on branch" > $testroot/content.expected
107 818c7501 2019-07-11 stsp cat $testroot/wt/epsilon/new > $testroot/content
108 818c7501 2019-07-11 stsp cmp -s $testroot/content.expected $testroot/content
109 818c7501 2019-07-11 stsp ret="$?"
110 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
111 818c7501 2019-07-11 stsp diff -u $testroot/content.expected $testroot/content
112 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
113 818c7501 2019-07-11 stsp return 1
114 818c7501 2019-07-11 stsp fi
115 818c7501 2019-07-11 stsp
116 818c7501 2019-07-11 stsp (cd $testroot/wt && got status > $testroot/stdout)
117 818c7501 2019-07-11 stsp
118 818c7501 2019-07-11 stsp echo -n > $testroot/stdout.expected
119 818c7501 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
120 818c7501 2019-07-11 stsp ret="$?"
121 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
122 818c7501 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
123 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
124 818c7501 2019-07-11 stsp return 1
125 818c7501 2019-07-11 stsp fi
126 818c7501 2019-07-11 stsp
127 818c7501 2019-07-11 stsp (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
128 818c7501 2019-07-11 stsp echo "commit $new_commit2 (newbranch)" > $testroot/stdout.expected
129 818c7501 2019-07-11 stsp echo "commit $new_commit1" >> $testroot/stdout.expected
130 818c7501 2019-07-11 stsp echo "commit $master_commit (master)" >> $testroot/stdout.expected
131 818c7501 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
132 818c7501 2019-07-11 stsp ret="$?"
133 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
134 818c7501 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
135 818c7501 2019-07-11 stsp fi
136 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
137 818c7501 2019-07-11 stsp }
138 818c7501 2019-07-11 stsp
139 818c7501 2019-07-11 stsp function test_rebase_ancestry_check {
140 818c7501 2019-07-11 stsp local testroot=`test_init rebase_ancestry_check`
141 818c7501 2019-07-11 stsp
142 818c7501 2019-07-11 stsp got checkout $testroot/repo $testroot/wt > /dev/null
143 818c7501 2019-07-11 stsp ret="$?"
144 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
145 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
146 818c7501 2019-07-11 stsp return 1
147 818c7501 2019-07-11 stsp fi
148 818c7501 2019-07-11 stsp
149 818c7501 2019-07-11 stsp (cd $testroot/repo && git checkout -q -b newbranch)
150 818c7501 2019-07-11 stsp echo "modified delta on branch" > $testroot/repo/gamma/delta
151 818c7501 2019-07-11 stsp git_commit $testroot/repo -m "committing to delta on newbranch"
152 818c7501 2019-07-11 stsp
153 818c7501 2019-07-11 stsp (cd $testroot/wt && got rebase newbranch > $testroot/stdout \
154 818c7501 2019-07-11 stsp 2> $testroot/stderr)
155 818c7501 2019-07-11 stsp
156 818c7501 2019-07-11 stsp echo -n > $testroot/stdout.expected
157 818c7501 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
158 818c7501 2019-07-11 stsp ret="$?"
159 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
160 818c7501 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
161 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
162 818c7501 2019-07-11 stsp return 1
163 818c7501 2019-07-11 stsp fi
164 818c7501 2019-07-11 stsp
165 818c7501 2019-07-11 stsp echo -n "got: specified branch resolves to a commit " \
166 818c7501 2019-07-11 stsp > $testroot/stderr.expected
167 818c7501 2019-07-11 stsp echo "which is already contained in work tree's branch" \
168 818c7501 2019-07-11 stsp >> $testroot/stderr.expected
169 818c7501 2019-07-11 stsp cmp -s $testroot/stderr.expected $testroot/stderr
170 818c7501 2019-07-11 stsp ret="$?"
171 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
172 818c7501 2019-07-11 stsp diff -u $testroot/stderr.expected $testroot/stderr
173 818c7501 2019-07-11 stsp fi
174 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
175 818c7501 2019-07-11 stsp }
176 818c7501 2019-07-11 stsp
177 818c7501 2019-07-11 stsp function test_rebase_continue {
178 818c7501 2019-07-11 stsp local testroot=`test_init rebase_continue`
179 818c7501 2019-07-11 stsp
180 818c7501 2019-07-11 stsp (cd $testroot/repo && git checkout -q -b newbranch)
181 818c7501 2019-07-11 stsp echo "modified alpha on branch" > $testroot/repo/alpha
182 818c7501 2019-07-11 stsp git_commit $testroot/repo -m "committing to alpha on newbranch"
183 818c7501 2019-07-11 stsp local orig_commit1=`git_show_head $testroot/repo`
184 818c7501 2019-07-11 stsp
185 818c7501 2019-07-11 stsp (cd $testroot/repo && git checkout -q master)
186 818c7501 2019-07-11 stsp echo "modified alpha on master" > $testroot/repo/alpha
187 818c7501 2019-07-11 stsp git_commit $testroot/repo -m "committing to alpha on master"
188 818c7501 2019-07-11 stsp local master_commit=`git_show_head $testroot/repo`
189 818c7501 2019-07-11 stsp
190 818c7501 2019-07-11 stsp got checkout $testroot/repo $testroot/wt > /dev/null
191 818c7501 2019-07-11 stsp ret="$?"
192 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
193 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
194 818c7501 2019-07-11 stsp return 1
195 818c7501 2019-07-11 stsp fi
196 818c7501 2019-07-11 stsp
197 818c7501 2019-07-11 stsp (cd $testroot/wt && got rebase newbranch > $testroot/stdout \
198 818c7501 2019-07-11 stsp 2> $testroot/stderr)
199 818c7501 2019-07-11 stsp
200 818c7501 2019-07-11 stsp echo "C alpha" > $testroot/stdout.expected
201 818c7501 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
202 818c7501 2019-07-11 stsp ret="$?"
203 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
204 818c7501 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
205 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
206 818c7501 2019-07-11 stsp return 1
207 818c7501 2019-07-11 stsp fi
208 818c7501 2019-07-11 stsp
209 818c7501 2019-07-11 stsp echo "got: conflicts must be resolved before rebase can be resumed" \
210 818c7501 2019-07-11 stsp > $testroot/stderr.expected
211 818c7501 2019-07-11 stsp cmp -s $testroot/stderr.expected $testroot/stderr
212 818c7501 2019-07-11 stsp ret="$?"
213 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
214 818c7501 2019-07-11 stsp diff -u $testroot/stderr.expected $testroot/stderr
215 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
216 818c7501 2019-07-11 stsp return 1
217 818c7501 2019-07-11 stsp fi
218 818c7501 2019-07-11 stsp
219 818c7501 2019-07-11 stsp echo "<<<<<<< commit $orig_commit1" > $testroot/content.expected
220 818c7501 2019-07-11 stsp echo "modified alpha on branch" >> $testroot/content.expected
221 818c7501 2019-07-11 stsp echo "=======" >> $testroot/content.expected
222 818c7501 2019-07-11 stsp echo "modified alpha on master" >> $testroot/content.expected
223 818c7501 2019-07-11 stsp echo '>>>>>>> alpha' >> $testroot/content.expected
224 818c7501 2019-07-11 stsp cat $testroot/wt/alpha > $testroot/content
225 818c7501 2019-07-11 stsp cmp -s $testroot/content.expected $testroot/content
226 818c7501 2019-07-11 stsp ret="$?"
227 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
228 818c7501 2019-07-11 stsp diff -u $testroot/content.expected $testroot/content
229 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
230 818c7501 2019-07-11 stsp return 1
231 818c7501 2019-07-11 stsp fi
232 818c7501 2019-07-11 stsp
233 818c7501 2019-07-11 stsp (cd $testroot/wt && got status > $testroot/stdout)
234 818c7501 2019-07-11 stsp
235 818c7501 2019-07-11 stsp echo "C alpha" > $testroot/stdout.expected
236 818c7501 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
237 818c7501 2019-07-11 stsp ret="$?"
238 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
239 818c7501 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
240 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
241 818c7501 2019-07-11 stsp return 1
242 818c7501 2019-07-11 stsp fi
243 818c7501 2019-07-11 stsp
244 818c7501 2019-07-11 stsp # resolve the conflict
245 818c7501 2019-07-11 stsp echo "modified alpha on branch and master" > $testroot/wt/alpha
246 818c7501 2019-07-11 stsp
247 818c7501 2019-07-11 stsp (cd $testroot/wt && got rebase -c > $testroot/stdout)
248 818c7501 2019-07-11 stsp
249 818c7501 2019-07-11 stsp (cd $testroot/repo && git checkout -q newbranch)
250 818c7501 2019-07-11 stsp local new_commit1=`git_show_head $testroot/repo`
251 818c7501 2019-07-11 stsp
252 818c7501 2019-07-11 stsp local short_orig_commit1=`trim_obj_id 28 $orig_commit1`
253 818c7501 2019-07-11 stsp local short_new_commit1=`trim_obj_id 28 $new_commit1`
254 818c7501 2019-07-11 stsp
255 818c7501 2019-07-11 stsp echo -n "$short_orig_commit1 -> $short_new_commit1" \
256 818c7501 2019-07-11 stsp > $testroot/stdout.expected
257 818c7501 2019-07-11 stsp echo ": committing to alpha on newbranch" >> $testroot/stdout.expected
258 818c7501 2019-07-11 stsp echo "Switching work tree to refs/heads/newbranch" \
259 818c7501 2019-07-11 stsp >> $testroot/stdout.expected
260 818c7501 2019-07-11 stsp
261 818c7501 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
262 818c7501 2019-07-11 stsp ret="$?"
263 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
264 818c7501 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
265 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
266 818c7501 2019-07-11 stsp return 1
267 818c7501 2019-07-11 stsp fi
268 818c7501 2019-07-11 stsp
269 818c7501 2019-07-11 stsp
270 818c7501 2019-07-11 stsp (cd $testroot/wt && got log -l2 | grep ^commit > $testroot/stdout)
271 818c7501 2019-07-11 stsp echo "commit $new_commit1 (newbranch)" > $testroot/stdout.expected
272 818c7501 2019-07-11 stsp echo "commit $master_commit (master)" >> $testroot/stdout.expected
273 818c7501 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
274 818c7501 2019-07-11 stsp ret="$?"
275 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
276 818c7501 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
277 818c7501 2019-07-11 stsp fi
278 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
279 818c7501 2019-07-11 stsp }
280 818c7501 2019-07-11 stsp
281 818c7501 2019-07-11 stsp function test_rebase_abort {
282 818c7501 2019-07-11 stsp local testroot=`test_init rebase_abort`
283 818c7501 2019-07-11 stsp
284 818c7501 2019-07-11 stsp local init_commit=`git_show_head $testroot/repo`
285 818c7501 2019-07-11 stsp
286 818c7501 2019-07-11 stsp (cd $testroot/repo && git checkout -q -b newbranch)
287 818c7501 2019-07-11 stsp echo "modified alpha on branch" > $testroot/repo/alpha
288 818c7501 2019-07-11 stsp git_commit $testroot/repo -m "committing to alpha on newbranch"
289 818c7501 2019-07-11 stsp local orig_commit1=`git_show_head $testroot/repo`
290 818c7501 2019-07-11 stsp
291 818c7501 2019-07-11 stsp (cd $testroot/repo && git checkout -q master)
292 818c7501 2019-07-11 stsp echo "modified alpha on master" > $testroot/repo/alpha
293 818c7501 2019-07-11 stsp git_commit $testroot/repo -m "committing to alpha on master"
294 818c7501 2019-07-11 stsp local master_commit=`git_show_head $testroot/repo`
295 818c7501 2019-07-11 stsp
296 818c7501 2019-07-11 stsp got checkout $testroot/repo $testroot/wt > /dev/null
297 818c7501 2019-07-11 stsp ret="$?"
298 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
299 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
300 818c7501 2019-07-11 stsp return 1
301 818c7501 2019-07-11 stsp fi
302 818c7501 2019-07-11 stsp
303 818c7501 2019-07-11 stsp (cd $testroot/wt && got rebase newbranch > $testroot/stdout \
304 818c7501 2019-07-11 stsp 2> $testroot/stderr)
305 818c7501 2019-07-11 stsp
306 818c7501 2019-07-11 stsp echo "C alpha" > $testroot/stdout.expected
307 818c7501 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
308 818c7501 2019-07-11 stsp ret="$?"
309 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
310 818c7501 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
311 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
312 818c7501 2019-07-11 stsp return 1
313 818c7501 2019-07-11 stsp fi
314 818c7501 2019-07-11 stsp
315 818c7501 2019-07-11 stsp echo "got: conflicts must be resolved before rebase can be resumed" \
316 818c7501 2019-07-11 stsp > $testroot/stderr.expected
317 818c7501 2019-07-11 stsp cmp -s $testroot/stderr.expected $testroot/stderr
318 818c7501 2019-07-11 stsp ret="$?"
319 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
320 818c7501 2019-07-11 stsp diff -u $testroot/stderr.expected $testroot/stderr
321 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
322 818c7501 2019-07-11 stsp return 1
323 818c7501 2019-07-11 stsp fi
324 818c7501 2019-07-11 stsp
325 818c7501 2019-07-11 stsp echo "<<<<<<< commit $orig_commit1" > $testroot/content.expected
326 818c7501 2019-07-11 stsp echo "modified alpha on branch" >> $testroot/content.expected
327 818c7501 2019-07-11 stsp echo "=======" >> $testroot/content.expected
328 818c7501 2019-07-11 stsp echo "modified alpha on master" >> $testroot/content.expected
329 818c7501 2019-07-11 stsp echo '>>>>>>> alpha' >> $testroot/content.expected
330 818c7501 2019-07-11 stsp cat $testroot/wt/alpha > $testroot/content
331 818c7501 2019-07-11 stsp cmp -s $testroot/content.expected $testroot/content
332 818c7501 2019-07-11 stsp ret="$?"
333 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
334 818c7501 2019-07-11 stsp diff -u $testroot/content.expected $testroot/content
335 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
336 818c7501 2019-07-11 stsp return 1
337 818c7501 2019-07-11 stsp fi
338 818c7501 2019-07-11 stsp
339 818c7501 2019-07-11 stsp (cd $testroot/wt && got status > $testroot/stdout)
340 818c7501 2019-07-11 stsp
341 818c7501 2019-07-11 stsp echo "C alpha" > $testroot/stdout.expected
342 818c7501 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
343 818c7501 2019-07-11 stsp ret="$?"
344 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
345 818c7501 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
346 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
347 818c7501 2019-07-11 stsp return 1
348 818c7501 2019-07-11 stsp fi
349 818c7501 2019-07-11 stsp
350 818c7501 2019-07-11 stsp (cd $testroot/wt && got rebase -a > $testroot/stdout)
351 818c7501 2019-07-11 stsp
352 818c7501 2019-07-11 stsp (cd $testroot/repo && git checkout -q newbranch)
353 818c7501 2019-07-11 stsp
354 818c7501 2019-07-11 stsp echo "Switching work tree to refs/heads/master" \
355 818c7501 2019-07-11 stsp > $testroot/stdout.expected
356 818c7501 2019-07-11 stsp echo 'R alpha' >> $testroot/stdout.expected
357 818c7501 2019-07-11 stsp echo "Rebase of refs/heads/newbranch aborted" \
358 818c7501 2019-07-11 stsp >> $testroot/stdout.expected
359 818c7501 2019-07-11 stsp
360 818c7501 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
361 818c7501 2019-07-11 stsp ret="$?"
362 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
363 818c7501 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
364 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
365 818c7501 2019-07-11 stsp return 1
366 818c7501 2019-07-11 stsp fi
367 818c7501 2019-07-11 stsp
368 818c7501 2019-07-11 stsp echo "modified alpha on master" > $testroot/content.expected
369 818c7501 2019-07-11 stsp cat $testroot/wt/alpha > $testroot/content
370 818c7501 2019-07-11 stsp cmp -s $testroot/content.expected $testroot/content
371 818c7501 2019-07-11 stsp ret="$?"
372 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
373 818c7501 2019-07-11 stsp diff -u $testroot/content.expected $testroot/content
374 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
375 818c7501 2019-07-11 stsp return 1
376 818c7501 2019-07-11 stsp fi
377 818c7501 2019-07-11 stsp
378 818c7501 2019-07-11 stsp (cd $testroot/wt && got log -l3 -c newbranch \
379 818c7501 2019-07-11 stsp | grep ^commit > $testroot/stdout)
380 818c7501 2019-07-11 stsp echo "commit $orig_commit1 (newbranch)" > $testroot/stdout.expected
381 818c7501 2019-07-11 stsp echo "commit $init_commit" >> $testroot/stdout.expected
382 818c7501 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
383 818c7501 2019-07-11 stsp ret="$?"
384 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
385 818c7501 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
386 818c7501 2019-07-11 stsp fi
387 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
388 818c7501 2019-07-11 stsp }
389 818c7501 2019-07-11 stsp
390 818c7501 2019-07-11 stsp run_test test_rebase_basic
391 818c7501 2019-07-11 stsp run_test test_rebase_ancestry_check
392 818c7501 2019-07-11 stsp run_test test_rebase_continue
393 818c7501 2019-07-11 stsp run_test test_rebase_abort