3 5aa81393 2020-01-06 stsp # Copyright (c) 2019, 2020 Stefan Sperling <stsp@openbsd.org>
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.
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.
17 818c7501 2019-07-11 stsp . ./common.sh
19 818c7501 2019-07-11 stsp function test_rebase_basic {
20 818c7501 2019-07-11 stsp local testroot=`test_init rebase_basic`
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"
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"
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`
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`
40 818c7501 2019-07-11 stsp got checkout $testroot/repo $testroot/wt > /dev/null
42 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
43 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
47 818c7501 2019-07-11 stsp (cd $testroot/wt && got rebase newbranch > $testroot/stdout)
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`
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`
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
72 818c7501 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
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"
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
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"
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
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"
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"
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
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"
116 818c7501 2019-07-11 stsp (cd $testroot/wt && got status > $testroot/stdout)
118 818c7501 2019-07-11 stsp echo -n > $testroot/stdout.expected
119 818c7501 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
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"
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
133 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
134 818c7501 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
136 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
139 818c7501 2019-07-11 stsp function test_rebase_ancestry_check {
140 818c7501 2019-07-11 stsp local testroot=`test_init rebase_ancestry_check`
142 818c7501 2019-07-11 stsp got checkout $testroot/repo $testroot/wt > /dev/null
144 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
145 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
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"
153 818c7501 2019-07-11 stsp (cd $testroot/wt && got rebase newbranch > $testroot/stdout \
154 818c7501 2019-07-11 stsp 2> $testroot/stderr)
156 818c7501 2019-07-11 stsp echo -n > $testroot/stdout.expected
157 818c7501 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
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"
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
171 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
172 818c7501 2019-07-11 stsp diff -u $testroot/stderr.expected $testroot/stderr
174 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
177 818c7501 2019-07-11 stsp function test_rebase_continue {
178 818c7501 2019-07-11 stsp local testroot=`test_init rebase_continue`
179 f69721c3 2019-10-21 stsp local init_commit=`git_show_head $testroot/repo`
181 818c7501 2019-07-11 stsp (cd $testroot/repo && git checkout -q -b newbranch)
182 818c7501 2019-07-11 stsp echo "modified alpha on branch" > $testroot/repo/alpha
183 818c7501 2019-07-11 stsp git_commit $testroot/repo -m "committing to alpha on newbranch"
184 818c7501 2019-07-11 stsp local orig_commit1=`git_show_head $testroot/repo`
185 a0ea4fc0 2020-02-28 stsp local short_orig_commit1=`trim_obj_id 28 $orig_commit1`
187 818c7501 2019-07-11 stsp (cd $testroot/repo && git checkout -q master)
188 818c7501 2019-07-11 stsp echo "modified alpha on master" > $testroot/repo/alpha
189 818c7501 2019-07-11 stsp git_commit $testroot/repo -m "committing to alpha on master"
190 818c7501 2019-07-11 stsp local master_commit=`git_show_head $testroot/repo`
192 818c7501 2019-07-11 stsp got checkout $testroot/repo $testroot/wt > /dev/null
194 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
195 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
199 818c7501 2019-07-11 stsp (cd $testroot/wt && got rebase newbranch > $testroot/stdout \
200 818c7501 2019-07-11 stsp 2> $testroot/stderr)
202 818c7501 2019-07-11 stsp echo "C alpha" > $testroot/stdout.expected
203 a0ea4fc0 2020-02-28 stsp echo -n "$short_orig_commit1 -> merge conflict" \
204 a0ea4fc0 2020-02-28 stsp >> $testroot/stdout.expected
205 a0ea4fc0 2020-02-28 stsp echo ": committing to alpha on newbranch" >> $testroot/stdout.expected
206 818c7501 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
208 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
209 818c7501 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
210 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
214 11495e04 2019-07-12 stsp echo "got: conflicts must be resolved before rebasing can continue" \
215 818c7501 2019-07-11 stsp > $testroot/stderr.expected
216 818c7501 2019-07-11 stsp cmp -s $testroot/stderr.expected $testroot/stderr
218 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
219 818c7501 2019-07-11 stsp diff -u $testroot/stderr.expected $testroot/stderr
220 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
224 f69721c3 2019-10-21 stsp echo "<<<<<<< merged change: commit $orig_commit1" \
225 f69721c3 2019-10-21 stsp > $testroot/content.expected
226 818c7501 2019-07-11 stsp echo "modified alpha on branch" >> $testroot/content.expected
227 f69721c3 2019-10-21 stsp echo "||||||| 3-way merge base: commit $init_commit" \
228 f69721c3 2019-10-21 stsp >> $testroot/content.expected
229 d136cfcb 2019-10-12 stsp echo "alpha" >> $testroot/content.expected
230 818c7501 2019-07-11 stsp echo "=======" >> $testroot/content.expected
231 818c7501 2019-07-11 stsp echo "modified alpha on master" >> $testroot/content.expected
232 f69721c3 2019-10-21 stsp echo '>>>>>>>' >> $testroot/content.expected
233 818c7501 2019-07-11 stsp cat $testroot/wt/alpha > $testroot/content
234 818c7501 2019-07-11 stsp cmp -s $testroot/content.expected $testroot/content
236 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
237 818c7501 2019-07-11 stsp diff -u $testroot/content.expected $testroot/content
238 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
242 818c7501 2019-07-11 stsp (cd $testroot/wt && got status > $testroot/stdout)
244 818c7501 2019-07-11 stsp echo "C alpha" > $testroot/stdout.expected
245 818c7501 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
247 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
248 818c7501 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
249 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
253 818c7501 2019-07-11 stsp # resolve the conflict
254 818c7501 2019-07-11 stsp echo "modified alpha on branch and master" > $testroot/wt/alpha
256 f032f1f7 2019-08-04 stsp # test interaction of 'got stage' and rebase -c
257 f032f1f7 2019-08-04 stsp (cd $testroot/wt && got stage alpha > /dev/null)
258 f032f1f7 2019-08-04 stsp (cd $testroot/wt && got rebase -c > $testroot/stdout \
259 f032f1f7 2019-08-04 stsp 2> $testroot/stderr)
261 f032f1f7 2019-08-04 stsp if [ "$ret" == "0" ]; then
262 f032f1f7 2019-08-04 stsp echo "rebase succeeded unexpectedly" >&2
263 f032f1f7 2019-08-04 stsp test_done "$testroot" "1"
266 f032f1f7 2019-08-04 stsp echo -n "got: work tree contains files with staged changes; " \
267 f032f1f7 2019-08-04 stsp > $testroot/stderr.expected
268 f032f1f7 2019-08-04 stsp echo "these changes must be committed or unstaged first" \
269 f032f1f7 2019-08-04 stsp >> $testroot/stderr.expected
270 f032f1f7 2019-08-04 stsp cmp -s $testroot/stderr.expected $testroot/stderr
272 f032f1f7 2019-08-04 stsp if [ "$ret" != "0" ]; then
273 f032f1f7 2019-08-04 stsp diff -u $testroot/stderr.expected $testroot/stderr
274 f032f1f7 2019-08-04 stsp test_done "$testroot" "$ret"
278 f032f1f7 2019-08-04 stsp (cd $testroot/wt && got unstage alpha > /dev/null)
279 818c7501 2019-07-11 stsp (cd $testroot/wt && got rebase -c > $testroot/stdout)
281 818c7501 2019-07-11 stsp (cd $testroot/repo && git checkout -q newbranch)
282 818c7501 2019-07-11 stsp local new_commit1=`git_show_head $testroot/repo`
283 818c7501 2019-07-11 stsp local short_new_commit1=`trim_obj_id 28 $new_commit1`
285 818c7501 2019-07-11 stsp echo -n "$short_orig_commit1 -> $short_new_commit1" \
286 818c7501 2019-07-11 stsp > $testroot/stdout.expected
287 818c7501 2019-07-11 stsp echo ": committing to alpha on newbranch" >> $testroot/stdout.expected
288 818c7501 2019-07-11 stsp echo "Switching work tree to refs/heads/newbranch" \
289 818c7501 2019-07-11 stsp >> $testroot/stdout.expected
291 818c7501 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
293 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
294 818c7501 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
295 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
300 818c7501 2019-07-11 stsp (cd $testroot/wt && got log -l2 | grep ^commit > $testroot/stdout)
301 818c7501 2019-07-11 stsp echo "commit $new_commit1 (newbranch)" > $testroot/stdout.expected
302 818c7501 2019-07-11 stsp echo "commit $master_commit (master)" >> $testroot/stdout.expected
303 818c7501 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
305 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
306 818c7501 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
308 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
311 818c7501 2019-07-11 stsp function test_rebase_abort {
312 818c7501 2019-07-11 stsp local testroot=`test_init rebase_abort`
314 818c7501 2019-07-11 stsp local init_commit=`git_show_head $testroot/repo`
316 818c7501 2019-07-11 stsp (cd $testroot/repo && git checkout -q -b newbranch)
317 818c7501 2019-07-11 stsp echo "modified alpha on branch" > $testroot/repo/alpha
318 818c7501 2019-07-11 stsp git_commit $testroot/repo -m "committing to alpha on newbranch"
319 818c7501 2019-07-11 stsp local orig_commit1=`git_show_head $testroot/repo`
320 a0ea4fc0 2020-02-28 stsp local short_orig_commit1=`trim_obj_id 28 $orig_commit1`
322 818c7501 2019-07-11 stsp (cd $testroot/repo && git checkout -q master)
323 818c7501 2019-07-11 stsp echo "modified alpha on master" > $testroot/repo/alpha
324 818c7501 2019-07-11 stsp git_commit $testroot/repo -m "committing to alpha on master"
325 818c7501 2019-07-11 stsp local master_commit=`git_show_head $testroot/repo`
327 818c7501 2019-07-11 stsp got checkout $testroot/repo $testroot/wt > /dev/null
329 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
330 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
334 818c7501 2019-07-11 stsp (cd $testroot/wt && got rebase newbranch > $testroot/stdout \
335 818c7501 2019-07-11 stsp 2> $testroot/stderr)
337 818c7501 2019-07-11 stsp echo "C alpha" > $testroot/stdout.expected
338 a0ea4fc0 2020-02-28 stsp echo -n "$short_orig_commit1 -> merge conflict" \
339 a0ea4fc0 2020-02-28 stsp >> $testroot/stdout.expected
340 a0ea4fc0 2020-02-28 stsp echo ": committing to alpha on newbranch" >> $testroot/stdout.expected
341 818c7501 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
343 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
344 818c7501 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
345 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
349 11495e04 2019-07-12 stsp echo "got: conflicts must be resolved before rebasing can continue" \
350 818c7501 2019-07-11 stsp > $testroot/stderr.expected
351 818c7501 2019-07-11 stsp cmp -s $testroot/stderr.expected $testroot/stderr
353 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
354 818c7501 2019-07-11 stsp diff -u $testroot/stderr.expected $testroot/stderr
355 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
359 f69721c3 2019-10-21 stsp echo "<<<<<<< merged change: commit $orig_commit1" \
360 f69721c3 2019-10-21 stsp > $testroot/content.expected
361 818c7501 2019-07-11 stsp echo "modified alpha on branch" >> $testroot/content.expected
362 f69721c3 2019-10-21 stsp echo "||||||| 3-way merge base: commit $init_commit" \
363 f69721c3 2019-10-21 stsp >> $testroot/content.expected
364 d136cfcb 2019-10-12 stsp echo "alpha" >> $testroot/content.expected
365 818c7501 2019-07-11 stsp echo "=======" >> $testroot/content.expected
366 818c7501 2019-07-11 stsp echo "modified alpha on master" >> $testroot/content.expected
367 f69721c3 2019-10-21 stsp echo '>>>>>>>' >> $testroot/content.expected
368 818c7501 2019-07-11 stsp cat $testroot/wt/alpha > $testroot/content
369 818c7501 2019-07-11 stsp cmp -s $testroot/content.expected $testroot/content
371 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
372 818c7501 2019-07-11 stsp diff -u $testroot/content.expected $testroot/content
373 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
377 818c7501 2019-07-11 stsp (cd $testroot/wt && got status > $testroot/stdout)
379 818c7501 2019-07-11 stsp echo "C alpha" > $testroot/stdout.expected
380 818c7501 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
382 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
383 818c7501 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
384 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
388 818c7501 2019-07-11 stsp (cd $testroot/wt && got rebase -a > $testroot/stdout)
390 818c7501 2019-07-11 stsp (cd $testroot/repo && git checkout -q newbranch)
392 818c7501 2019-07-11 stsp echo "Switching work tree to refs/heads/master" \
393 818c7501 2019-07-11 stsp > $testroot/stdout.expected
394 818c7501 2019-07-11 stsp echo 'R alpha' >> $testroot/stdout.expected
395 818c7501 2019-07-11 stsp echo "Rebase of refs/heads/newbranch aborted" \
396 818c7501 2019-07-11 stsp >> $testroot/stdout.expected
398 818c7501 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
400 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
401 818c7501 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
402 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
406 818c7501 2019-07-11 stsp echo "modified alpha on master" > $testroot/content.expected
407 818c7501 2019-07-11 stsp cat $testroot/wt/alpha > $testroot/content
408 818c7501 2019-07-11 stsp cmp -s $testroot/content.expected $testroot/content
410 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
411 818c7501 2019-07-11 stsp diff -u $testroot/content.expected $testroot/content
412 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
416 818c7501 2019-07-11 stsp (cd $testroot/wt && got log -l3 -c newbranch \
417 818c7501 2019-07-11 stsp | grep ^commit > $testroot/stdout)
418 818c7501 2019-07-11 stsp echo "commit $orig_commit1 (newbranch)" > $testroot/stdout.expected
419 818c7501 2019-07-11 stsp echo "commit $init_commit" >> $testroot/stdout.expected
420 818c7501 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
422 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
423 818c7501 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
425 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
428 ff0d2220 2019-07-11 stsp function test_rebase_no_op_change {
429 ff0d2220 2019-07-11 stsp local testroot=`test_init rebase_no_op_change`
430 ff0d2220 2019-07-11 stsp local init_commit=`git_show_head $testroot/repo`
432 ff0d2220 2019-07-11 stsp (cd $testroot/repo && git checkout -q -b newbranch)
433 ff0d2220 2019-07-11 stsp echo "modified alpha on branch" > $testroot/repo/alpha
434 ff0d2220 2019-07-11 stsp git_commit $testroot/repo -m "committing to alpha on newbranch"
435 ff0d2220 2019-07-11 stsp local orig_commit1=`git_show_head $testroot/repo`
436 a0ea4fc0 2020-02-28 stsp local short_orig_commit1=`trim_obj_id 28 $orig_commit1`
438 ff0d2220 2019-07-11 stsp (cd $testroot/repo && git checkout -q master)
439 ff0d2220 2019-07-11 stsp echo "modified alpha on master" > $testroot/repo/alpha
440 ff0d2220 2019-07-11 stsp git_commit $testroot/repo -m "committing to alpha on master"
441 ff0d2220 2019-07-11 stsp local master_commit=`git_show_head $testroot/repo`
443 ff0d2220 2019-07-11 stsp got checkout $testroot/repo $testroot/wt > /dev/null
445 ff0d2220 2019-07-11 stsp if [ "$ret" != "0" ]; then
446 ff0d2220 2019-07-11 stsp test_done "$testroot" "$ret"
450 ff0d2220 2019-07-11 stsp (cd $testroot/wt && got rebase newbranch > $testroot/stdout \
451 ff0d2220 2019-07-11 stsp 2> $testroot/stderr)
453 ff0d2220 2019-07-11 stsp echo "C alpha" > $testroot/stdout.expected
454 a0ea4fc0 2020-02-28 stsp echo -n "$short_orig_commit1 -> merge conflict" \
455 a0ea4fc0 2020-02-28 stsp >> $testroot/stdout.expected
456 a0ea4fc0 2020-02-28 stsp echo ": committing to alpha on newbranch" >> $testroot/stdout.expected
457 ff0d2220 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
459 ff0d2220 2019-07-11 stsp if [ "$ret" != "0" ]; then
460 ff0d2220 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
461 ff0d2220 2019-07-11 stsp test_done "$testroot" "$ret"
465 11495e04 2019-07-12 stsp echo "got: conflicts must be resolved before rebasing can continue" \
466 ff0d2220 2019-07-11 stsp > $testroot/stderr.expected
467 ff0d2220 2019-07-11 stsp cmp -s $testroot/stderr.expected $testroot/stderr
469 ff0d2220 2019-07-11 stsp if [ "$ret" != "0" ]; then
470 ff0d2220 2019-07-11 stsp diff -u $testroot/stderr.expected $testroot/stderr
471 ff0d2220 2019-07-11 stsp test_done "$testroot" "$ret"
475 f69721c3 2019-10-21 stsp echo "<<<<<<< merged change: commit $orig_commit1" \
476 f69721c3 2019-10-21 stsp > $testroot/content.expected
477 ff0d2220 2019-07-11 stsp echo "modified alpha on branch" >> $testroot/content.expected
478 f69721c3 2019-10-21 stsp echo "||||||| 3-way merge base: commit $init_commit" \
479 f69721c3 2019-10-21 stsp >> $testroot/content.expected
480 d136cfcb 2019-10-12 stsp echo "alpha" >> $testroot/content.expected
481 ff0d2220 2019-07-11 stsp echo "=======" >> $testroot/content.expected
482 ff0d2220 2019-07-11 stsp echo "modified alpha on master" >> $testroot/content.expected
483 f69721c3 2019-10-21 stsp echo '>>>>>>>' >> $testroot/content.expected
484 ff0d2220 2019-07-11 stsp cat $testroot/wt/alpha > $testroot/content
485 ff0d2220 2019-07-11 stsp cmp -s $testroot/content.expected $testroot/content
487 ff0d2220 2019-07-11 stsp if [ "$ret" != "0" ]; then
488 ff0d2220 2019-07-11 stsp diff -u $testroot/content.expected $testroot/content
489 ff0d2220 2019-07-11 stsp test_done "$testroot" "$ret"
493 ff0d2220 2019-07-11 stsp (cd $testroot/wt && got status > $testroot/stdout)
495 ff0d2220 2019-07-11 stsp echo "C alpha" > $testroot/stdout.expected
496 ff0d2220 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
498 ff0d2220 2019-07-11 stsp if [ "$ret" != "0" ]; then
499 ff0d2220 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
500 ff0d2220 2019-07-11 stsp test_done "$testroot" "$ret"
504 ff0d2220 2019-07-11 stsp # resolve the conflict
505 ff0d2220 2019-07-11 stsp echo "modified alpha on master" > $testroot/wt/alpha
507 ff0d2220 2019-07-11 stsp (cd $testroot/wt && got rebase -c > $testroot/stdout)
509 ff0d2220 2019-07-11 stsp (cd $testroot/repo && git checkout -q newbranch)
510 ff0d2220 2019-07-11 stsp local new_commit1=`git_show_head $testroot/repo`
512 ff0d2220 2019-07-11 stsp echo -n "$short_orig_commit1 -> no-op change" \
513 ff0d2220 2019-07-11 stsp > $testroot/stdout.expected
514 ff0d2220 2019-07-11 stsp echo ": committing to alpha on newbranch" >> $testroot/stdout.expected
515 ff0d2220 2019-07-11 stsp echo "Switching work tree to refs/heads/newbranch" \
516 ff0d2220 2019-07-11 stsp >> $testroot/stdout.expected
518 ff0d2220 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
520 ff0d2220 2019-07-11 stsp if [ "$ret" != "0" ]; then
521 ff0d2220 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
522 ff0d2220 2019-07-11 stsp test_done "$testroot" "$ret"
527 ff0d2220 2019-07-11 stsp (cd $testroot/wt && got log -l2 | grep ^commit > $testroot/stdout)
528 ff0d2220 2019-07-11 stsp echo "commit $master_commit (master, newbranch)" \
529 ff0d2220 2019-07-11 stsp > $testroot/stdout.expected
530 ff0d2220 2019-07-11 stsp echo "commit $init_commit" >> $testroot/stdout.expected
531 7d5807f4 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
533 7d5807f4 2019-07-11 stsp if [ "$ret" != "0" ]; then
534 7d5807f4 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
536 7d5807f4 2019-07-11 stsp test_done "$testroot" "$ret"
539 7d5807f4 2019-07-11 stsp function test_rebase_in_progress {
540 4ba9c4f6 2019-07-11 stsp local testroot=`test_init rebase_in_progress`
541 7d5807f4 2019-07-11 stsp local init_commit=`git_show_head $testroot/repo`
543 7d5807f4 2019-07-11 stsp (cd $testroot/repo && git checkout -q -b newbranch)
544 7d5807f4 2019-07-11 stsp echo "modified alpha on branch" > $testroot/repo/alpha
545 7d5807f4 2019-07-11 stsp git_commit $testroot/repo -m "committing to alpha on newbranch"
546 7d5807f4 2019-07-11 stsp local orig_commit1=`git_show_head $testroot/repo`
547 a0ea4fc0 2020-02-28 stsp local short_orig_commit1=`trim_obj_id 28 $orig_commit1`
549 7d5807f4 2019-07-11 stsp (cd $testroot/repo && git checkout -q master)
550 7d5807f4 2019-07-11 stsp echo "modified alpha on master" > $testroot/repo/alpha
551 7d5807f4 2019-07-11 stsp git_commit $testroot/repo -m "committing to alpha on master"
552 7d5807f4 2019-07-11 stsp local master_commit=`git_show_head $testroot/repo`
554 7d5807f4 2019-07-11 stsp got checkout $testroot/repo $testroot/wt > /dev/null
556 7d5807f4 2019-07-11 stsp if [ "$ret" != "0" ]; then
557 7d5807f4 2019-07-11 stsp test_done "$testroot" "$ret"
561 7d5807f4 2019-07-11 stsp (cd $testroot/wt && got rebase newbranch > $testroot/stdout \
562 7d5807f4 2019-07-11 stsp 2> $testroot/stderr)
564 7d5807f4 2019-07-11 stsp echo "C alpha" > $testroot/stdout.expected
565 a0ea4fc0 2020-02-28 stsp echo -n "$short_orig_commit1 -> merge conflict" \
566 a0ea4fc0 2020-02-28 stsp >> $testroot/stdout.expected
567 a0ea4fc0 2020-02-28 stsp echo ": committing to alpha on newbranch" >> $testroot/stdout.expected
568 7d5807f4 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
570 7d5807f4 2019-07-11 stsp if [ "$ret" != "0" ]; then
571 7d5807f4 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
572 7d5807f4 2019-07-11 stsp test_done "$testroot" "$ret"
576 11495e04 2019-07-12 stsp echo "got: conflicts must be resolved before rebasing can continue" \
577 7d5807f4 2019-07-11 stsp > $testroot/stderr.expected
578 7d5807f4 2019-07-11 stsp cmp -s $testroot/stderr.expected $testroot/stderr
580 7d5807f4 2019-07-11 stsp if [ "$ret" != "0" ]; then
581 7d5807f4 2019-07-11 stsp diff -u $testroot/stderr.expected $testroot/stderr
582 7d5807f4 2019-07-11 stsp test_done "$testroot" "$ret"
586 f69721c3 2019-10-21 stsp echo "<<<<<<< merged change: commit $orig_commit1" \
587 f69721c3 2019-10-21 stsp > $testroot/content.expected
588 7d5807f4 2019-07-11 stsp echo "modified alpha on branch" >> $testroot/content.expected
589 f69721c3 2019-10-21 stsp echo "||||||| 3-way merge base: commit $init_commit" \
590 f69721c3 2019-10-21 stsp >> $testroot/content.expected
591 d136cfcb 2019-10-12 stsp echo "alpha" >> $testroot/content.expected
592 7d5807f4 2019-07-11 stsp echo "=======" >> $testroot/content.expected
593 7d5807f4 2019-07-11 stsp echo "modified alpha on master" >> $testroot/content.expected
594 f69721c3 2019-10-21 stsp echo '>>>>>>>' >> $testroot/content.expected
595 7d5807f4 2019-07-11 stsp cat $testroot/wt/alpha > $testroot/content
596 7d5807f4 2019-07-11 stsp cmp -s $testroot/content.expected $testroot/content
598 7d5807f4 2019-07-11 stsp if [ "$ret" != "0" ]; then
599 7d5807f4 2019-07-11 stsp diff -u $testroot/content.expected $testroot/content
600 7d5807f4 2019-07-11 stsp test_done "$testroot" "$ret"
604 7d5807f4 2019-07-11 stsp (cd $testroot/wt && got status > $testroot/stdout)
606 7d5807f4 2019-07-11 stsp echo "C alpha" > $testroot/stdout.expected
607 ff0d2220 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
609 ff0d2220 2019-07-11 stsp if [ "$ret" != "0" ]; then
610 ff0d2220 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
611 7d5807f4 2019-07-11 stsp test_done "$testroot" "$ret"
615 7d5807f4 2019-07-11 stsp for cmd in update commit; do
616 7d5807f4 2019-07-11 stsp (cd $testroot/wt && got $cmd > $testroot/stdout \
617 7d5807f4 2019-07-11 stsp 2> $testroot/stderr)
619 7d5807f4 2019-07-11 stsp echo -n > $testroot/stdout.expected
620 7d5807f4 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
622 7d5807f4 2019-07-11 stsp if [ "$ret" != "0" ]; then
623 7d5807f4 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
624 7d5807f4 2019-07-11 stsp test_done "$testroot" "$ret"
628 7d5807f4 2019-07-11 stsp echo -n "got: a rebase operation is in progress in this " \
629 7d5807f4 2019-07-11 stsp > $testroot/stderr.expected
630 7d5807f4 2019-07-11 stsp echo "work tree and must be continued or aborted first" \
631 7d5807f4 2019-07-11 stsp >> $testroot/stderr.expected
632 7d5807f4 2019-07-11 stsp cmp -s $testroot/stderr.expected $testroot/stderr
634 7d5807f4 2019-07-11 stsp if [ "$ret" != "0" ]; then
635 7d5807f4 2019-07-11 stsp diff -u $testroot/stderr.expected $testroot/stderr
636 7d5807f4 2019-07-11 stsp test_done "$testroot" "$ret"
641 64c6d990 2019-07-11 stsp test_done "$testroot" "$ret"
644 64c6d990 2019-07-11 stsp function test_rebase_path_prefix {
645 64c6d990 2019-07-11 stsp local testroot=`test_init rebase_path_prefix`
647 64c6d990 2019-07-11 stsp (cd $testroot/repo && git checkout -q -b newbranch)
648 64c6d990 2019-07-11 stsp echo "modified delta on branch" > $testroot/repo/gamma/delta
649 64c6d990 2019-07-11 stsp git_commit $testroot/repo -m "committing to delta on newbranch"
651 64c6d990 2019-07-11 stsp local orig_commit1=`git_show_parent_commit $testroot/repo`
652 64c6d990 2019-07-11 stsp local orig_commit2=`git_show_head $testroot/repo`
654 64c6d990 2019-07-11 stsp (cd $testroot/repo && git checkout -q master)
655 64c6d990 2019-07-11 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
656 64c6d990 2019-07-11 stsp git_commit $testroot/repo -m "committing to zeta on master"
657 64c6d990 2019-07-11 stsp local master_commit=`git_show_head $testroot/repo`
659 64c6d990 2019-07-11 stsp got checkout -p epsilon $testroot/repo $testroot/wt > /dev/null
661 64c6d990 2019-07-11 stsp if [ "$ret" != "0" ]; then
662 64c6d990 2019-07-11 stsp test_done "$testroot" "$ret"
666 64c6d990 2019-07-11 stsp (cd $testroot/wt && got rebase newbranch \
667 64c6d990 2019-07-11 stsp > $testroot/stdout 2> $testroot/stderr)
669 64c6d990 2019-07-11 stsp echo -n > $testroot/stdout.expected
670 64c6d990 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
672 64c6d990 2019-07-11 stsp if [ "$ret" != "0" ]; then
673 64c6d990 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
674 64c6d990 2019-07-11 stsp test_done "$testroot" "$ret"
678 64c6d990 2019-07-11 stsp echo -n "got: cannot rebase branch which contains changes outside " \
679 64c6d990 2019-07-11 stsp > $testroot/stderr.expected
680 64c6d990 2019-07-11 stsp echo "of this work tree's path prefix" >> $testroot/stderr.expected
681 787c8eb6 2019-07-11 stsp cmp -s $testroot/stderr.expected $testroot/stderr
683 787c8eb6 2019-07-11 stsp if [ "$ret" != "0" ]; then
684 787c8eb6 2019-07-11 stsp diff -u $testroot/stderr.expected $testroot/stderr
686 787c8eb6 2019-07-11 stsp test_done "$testroot" "$ret"
689 787c8eb6 2019-07-11 stsp function test_rebase_preserves_logmsg {
690 787c8eb6 2019-07-11 stsp local testroot=`test_init rebase_preserves_logmsg`
692 787c8eb6 2019-07-11 stsp (cd $testroot/repo && git checkout -q -b newbranch)
693 787c8eb6 2019-07-11 stsp echo "modified delta on branch" > $testroot/repo/gamma/delta
694 787c8eb6 2019-07-11 stsp git_commit $testroot/repo -m "modified delta on newbranch"
696 787c8eb6 2019-07-11 stsp echo "modified alpha on branch" > $testroot/repo/alpha
697 787c8eb6 2019-07-11 stsp git_commit $testroot/repo -m "modified alpha on newbranch"
699 787c8eb6 2019-07-11 stsp (cd $testroot/repo && got log -c newbranch -l2 | grep -v ^date: \
700 787c8eb6 2019-07-11 stsp > $testroot/log.expected)
702 787c8eb6 2019-07-11 stsp local orig_commit1=`git_show_parent_commit $testroot/repo`
703 787c8eb6 2019-07-11 stsp local orig_commit2=`git_show_head $testroot/repo`
705 787c8eb6 2019-07-11 stsp (cd $testroot/repo && git checkout -q master)
706 787c8eb6 2019-07-11 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
707 787c8eb6 2019-07-11 stsp git_commit $testroot/repo -m "committing to zeta on master"
708 787c8eb6 2019-07-11 stsp local master_commit=`git_show_head $testroot/repo`
710 787c8eb6 2019-07-11 stsp got checkout $testroot/repo $testroot/wt > /dev/null
712 787c8eb6 2019-07-11 stsp if [ "$ret" != "0" ]; then
713 787c8eb6 2019-07-11 stsp test_done "$testroot" "$ret"
717 787c8eb6 2019-07-11 stsp (cd $testroot/wt && got rebase newbranch > /dev/null \
718 787c8eb6 2019-07-11 stsp 2> $testroot/stderr)
720 787c8eb6 2019-07-11 stsp (cd $testroot/repo && git checkout -q newbranch)
721 787c8eb6 2019-07-11 stsp local new_commit1=`git_show_parent_commit $testroot/repo`
722 787c8eb6 2019-07-11 stsp local new_commit2=`git_show_head $testroot/repo`
724 787c8eb6 2019-07-11 stsp echo -n > $testroot/stderr.expected
725 64c6d990 2019-07-11 stsp cmp -s $testroot/stderr.expected $testroot/stderr
727 64c6d990 2019-07-11 stsp if [ "$ret" != "0" ]; then
728 64c6d990 2019-07-11 stsp diff -u $testroot/stderr.expected $testroot/stderr
729 787c8eb6 2019-07-11 stsp test_done "$testroot" "$ret"
733 787c8eb6 2019-07-11 stsp (cd $testroot/wt && got log -c newbranch -l2 | grep -v ^date: \
734 787c8eb6 2019-07-11 stsp > $testroot/log)
735 787c8eb6 2019-07-11 stsp sed -i -e "s/$orig_commit1/$new_commit1/" $testroot/log.expected
736 787c8eb6 2019-07-11 stsp sed -i -e "s/$orig_commit2/$new_commit2/" $testroot/log.expected
737 787c8eb6 2019-07-11 stsp cmp -s $testroot/log.expected $testroot/log
739 787c8eb6 2019-07-11 stsp if [ "$ret" != "0" ]; then
740 787c8eb6 2019-07-11 stsp diff -u $testroot/log.expected $testroot/log
743 fc66b545 2019-08-12 stsp test_done "$testroot" "$ret"
746 fc66b545 2019-08-12 stsp function test_rebase_no_commits_to_rebase {
747 fc66b545 2019-08-12 stsp local testroot=`test_init rebase_no_commits_to_rebase`
749 fc66b545 2019-08-12 stsp got checkout $testroot/repo $testroot/wt > /dev/null
751 fc66b545 2019-08-12 stsp if [ "$ret" != "0" ]; then
752 fc66b545 2019-08-12 stsp test_done "$testroot" "$ret"
756 da76fce2 2020-02-24 stsp (cd $testroot/wt && got branch -n newbranch)
758 fc66b545 2019-08-12 stsp echo "modified alpha on master" > $testroot/wt/alpha
759 fc66b545 2019-08-12 stsp (cd $testroot/wt && got commit -m 'test rebase_no_commits_to_rebase' \
760 fc66b545 2019-08-12 stsp > /dev/null)
761 fc66b545 2019-08-12 stsp (cd $testroot/wt && got update > /dev/null)
763 fc66b545 2019-08-12 stsp (cd $testroot/wt && got rebase newbranch > $testroot/stdout \
764 fc66b545 2019-08-12 stsp 2> $testroot/stderr)
766 fc66b545 2019-08-12 stsp echo "got: no commits to rebase" > $testroot/stderr.expected
767 fc66b545 2019-08-12 stsp cmp -s $testroot/stderr.expected $testroot/stderr
769 fc66b545 2019-08-12 stsp if [ "$ret" != "0" ]; then
770 fc66b545 2019-08-12 stsp diff -u $testroot/stderr.expected $testroot/stderr
771 fc66b545 2019-08-12 stsp test_done "$testroot" "$ret"
775 fc66b545 2019-08-12 stsp echo "Rebase of refs/heads/newbranch aborted" \
776 fc66b545 2019-08-12 stsp > $testroot/stdout.expected
777 fc66b545 2019-08-12 stsp cmp -s $testroot/stdout.expected $testroot/stdout
779 fc66b545 2019-08-12 stsp if [ "$ret" != "0" ]; then
780 fc66b545 2019-08-12 stsp diff -u $testroot/stdout.expected $testroot/stdout
781 fc66b545 2019-08-12 stsp test_done "$testroot" "$ret"
785 fc66b545 2019-08-12 stsp (cd $testroot/wt && got update > $testroot/stdout)
786 fc66b545 2019-08-12 stsp echo "Already up-to-date" > $testroot/stdout.expected
787 fc66b545 2019-08-12 stsp cmp -s $testroot/stdout.expected $testroot/stdout
789 fc66b545 2019-08-12 stsp if [ "$ret" != "0" ]; then
790 fc66b545 2019-08-12 stsp diff -u $testroot/stdout.expected $testroot/stdout
792 ff0d2220 2019-07-11 stsp test_done "$testroot" "$ret"
795 38b0338b 2019-11-29 stsp function test_rebase_forward {
796 38b0338b 2019-11-29 stsp local testroot=`test_init rebase_forward`
797 38b0338b 2019-11-29 stsp local commit0=`git_show_head $testroot/repo`
799 38b0338b 2019-11-29 stsp got checkout $testroot/repo $testroot/wt > /dev/null
801 38b0338b 2019-11-29 stsp if [ "$ret" != "0" ]; then
802 38b0338b 2019-11-29 stsp test_done "$testroot" "$ret"
806 38b0338b 2019-11-29 stsp echo "change alpha 1" > $testroot/wt/alpha
807 38b0338b 2019-11-29 stsp (cd $testroot/wt && got commit -m 'test rebase_forward' \
808 38b0338b 2019-11-29 stsp > /dev/null)
809 38b0338b 2019-11-29 stsp local commit1=`git_show_head $testroot/repo`
811 38b0338b 2019-11-29 stsp echo "change alpha 2" > $testroot/wt/alpha
812 38b0338b 2019-11-29 stsp (cd $testroot/wt && got commit -m 'test rebase_forward' \
813 38b0338b 2019-11-29 stsp > /dev/null)
814 38b0338b 2019-11-29 stsp local commit2=`git_show_head $testroot/repo`
816 38b0338b 2019-11-29 stsp # Simulate a situation where fast-forward is required.
817 38b0338b 2019-11-29 stsp # We want to fast-forward master to origin/master:
818 38b0338b 2019-11-29 stsp # commit 3907e11dceaae2ca7f8db79c2af31794673945ad (origin/master)
819 38b0338b 2019-11-29 stsp # commit ffcffcd102cf1af6572fbdbb4cf07a0f1fd2d840 (master)
820 38b0338b 2019-11-29 stsp # commit 87a6a8a2263a15b61c016ff1720b24741d455eb5
821 38b0338b 2019-11-29 stsp (cd $testroot/repo && got ref -d master)
822 38b0338b 2019-11-29 stsp (cd $testroot/repo && got ref refs/heads/master $commit1)
823 38b0338b 2019-11-29 stsp (cd $testroot/repo && got ref refs/remotes/origin/master $commit2)
826 38b0338b 2019-11-29 stsp (cd $testroot/wt && got up -b origin/master > /dev/null)
828 38b0338b 2019-11-29 stsp (cd $testroot/wt && got rebase master \
829 38b0338b 2019-11-29 stsp > $testroot/stdout 2> $testroot/stderr)
831 38b0338b 2019-11-29 stsp echo "Forwarding refs/heads/master to commit $commit2" \
832 38b0338b 2019-11-29 stsp > $testroot/stdout.expected
833 38b0338b 2019-11-29 stsp echo "Switching work tree to refs/heads/master" \
834 38b0338b 2019-11-29 stsp >> $testroot/stdout.expected
835 38b0338b 2019-11-29 stsp cmp -s $testroot/stdout.expected $testroot/stdout
837 38b0338b 2019-11-29 stsp if [ "$ret" != "0" ]; then
838 38b0338b 2019-11-29 stsp diff -u $testroot/stdout.expected $testroot/stdout
839 38b0338b 2019-11-29 stsp test_done "$testroot" "$ret"
843 38b0338b 2019-11-29 stsp # Ensure that rebase operation was completed correctly
844 38b0338b 2019-11-29 stsp (cd $testroot/wt && got rebase -a \
845 38b0338b 2019-11-29 stsp > $testroot/stdout 2> $testroot/stderr)
846 38b0338b 2019-11-29 stsp echo -n "" > $testroot/stdout.expected
847 38b0338b 2019-11-29 stsp cmp -s $testroot/stdout.expected $testroot/stdout
849 38b0338b 2019-11-29 stsp if [ "$ret" != "0" ]; then
850 38b0338b 2019-11-29 stsp diff -u $testroot/stdout.expected $testroot/stdout
851 38b0338b 2019-11-29 stsp test_done "$testroot" "$ret"
854 38b0338b 2019-11-29 stsp echo "got: rebase operation not in progress" > $testroot/stderr.expected
855 38b0338b 2019-11-29 stsp cmp -s $testroot/stderr.expected $testroot/stderr
857 38b0338b 2019-11-29 stsp if [ "$ret" != "0" ]; then
858 38b0338b 2019-11-29 stsp diff -u $testroot/stderr.expected $testroot/stderr
859 38b0338b 2019-11-29 stsp test_done "$testroot" "$ret"
863 da76fce2 2020-02-24 stsp (cd $testroot/wt && got branch -n > $testroot/stdout)
864 38b0338b 2019-11-29 stsp echo "master" > $testroot/stdout.expected
865 38b0338b 2019-11-29 stsp cmp -s $testroot/stdout.expected $testroot/stdout
867 38b0338b 2019-11-29 stsp if [ "$ret" != "0" ]; then
868 38b0338b 2019-11-29 stsp diff -u $testroot/stdout.expected $testroot/stdout
869 38b0338b 2019-11-29 stsp test_done "$testroot" "$ret"
873 38b0338b 2019-11-29 stsp (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
874 38b0338b 2019-11-29 stsp echo "commit $commit2 (master, origin/master)" > $testroot/stdout.expected
875 38b0338b 2019-11-29 stsp echo "commit $commit1" >> $testroot/stdout.expected
876 38b0338b 2019-11-29 stsp echo "commit $commit0" >> $testroot/stdout.expected
877 38b0338b 2019-11-29 stsp cmp -s $testroot/stdout.expected $testroot/stdout
879 38b0338b 2019-11-29 stsp if [ "$ret" != "0" ]; then
880 38b0338b 2019-11-29 stsp diff -u $testroot/stdout.expected $testroot/stdout
882 38b0338b 2019-11-29 stsp test_done "$testroot" "$ret"
885 e51d7b55 2020-01-04 stsp function test_rebase_out_of_date {
886 e51d7b55 2020-01-04 stsp local testroot=`test_init rebase_out_of_date`
887 e51d7b55 2020-01-04 stsp local initial_commit=`git_show_head $testroot/repo`
889 e51d7b55 2020-01-04 stsp (cd $testroot/repo && git checkout -q -b newbranch)
890 e51d7b55 2020-01-04 stsp echo "modified delta on branch" > $testroot/repo/gamma/delta
891 e51d7b55 2020-01-04 stsp git_commit $testroot/repo -m "committing to delta on newbranch"
893 e51d7b55 2020-01-04 stsp echo "modified alpha on branch" > $testroot/repo/alpha
894 e51d7b55 2020-01-04 stsp (cd $testroot/repo && git rm -q beta)
895 e51d7b55 2020-01-04 stsp echo "new file on branch" > $testroot/repo/epsilon/new
896 e51d7b55 2020-01-04 stsp (cd $testroot/repo && git add epsilon/new)
897 e51d7b55 2020-01-04 stsp git_commit $testroot/repo -m "committing more changes on newbranch"
899 e51d7b55 2020-01-04 stsp local orig_commit1=`git_show_parent_commit $testroot/repo`
900 e51d7b55 2020-01-04 stsp local orig_commit2=`git_show_head $testroot/repo`
902 e51d7b55 2020-01-04 stsp (cd $testroot/repo && git checkout -q master)
903 e51d7b55 2020-01-04 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
904 e51d7b55 2020-01-04 stsp git_commit $testroot/repo -m "committing to zeta on master"
905 e51d7b55 2020-01-04 stsp local master_commit1=`git_show_head $testroot/repo`
907 e51d7b55 2020-01-04 stsp (cd $testroot/repo && git checkout -q master)
908 e51d7b55 2020-01-04 stsp echo "modified beta on master" > $testroot/repo/beta
909 e51d7b55 2020-01-04 stsp git_commit $testroot/repo -m "committing to beta on master"
910 e51d7b55 2020-01-04 stsp local master_commit2=`git_show_head $testroot/repo`
912 e51d7b55 2020-01-04 stsp got checkout -c $master_commit1 $testroot/repo $testroot/wt \
913 e51d7b55 2020-01-04 stsp > /dev/null
915 e51d7b55 2020-01-04 stsp if [ "$ret" != "0" ]; then
916 e51d7b55 2020-01-04 stsp test_done "$testroot" "$ret"
920 e51d7b55 2020-01-04 stsp (cd $testroot/wt && got rebase newbranch > $testroot/stdout \
921 e51d7b55 2020-01-04 stsp 2> $testroot/stderr)
923 e51d7b55 2020-01-04 stsp echo -n > $testroot/stdout.expected
924 e51d7b55 2020-01-04 stsp cmp -s $testroot/stdout.expected $testroot/stdout
926 e51d7b55 2020-01-04 stsp if [ "$ret" != "0" ]; then
927 e51d7b55 2020-01-04 stsp diff -u $testroot/stdout.expected $testroot/stdout
928 e51d7b55 2020-01-04 stsp test_done "$testroot" "$ret"
932 e51d7b55 2020-01-04 stsp echo -n "got: work tree must be updated before it can be " \
933 e51d7b55 2020-01-04 stsp > $testroot/stderr.expected
934 e51d7b55 2020-01-04 stsp echo "used to rebase a branch" >> $testroot/stderr.expected
935 e51d7b55 2020-01-04 stsp cmp -s $testroot/stderr.expected $testroot/stderr
937 e51d7b55 2020-01-04 stsp if [ "$ret" != "0" ]; then
938 e51d7b55 2020-01-04 stsp diff -u $testroot/stderr.expected $testroot/stderr
939 e51d7b55 2020-01-04 stsp test_done "$testroot" "$ret"
943 e51d7b55 2020-01-04 stsp (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
944 e51d7b55 2020-01-04 stsp echo "commit $master_commit2 (master)" > $testroot/stdout.expected
945 e51d7b55 2020-01-04 stsp echo "commit $master_commit1" >> $testroot/stdout.expected
946 e51d7b55 2020-01-04 stsp echo "commit $initial_commit" >> $testroot/stdout.expected
947 1ae0a341 2020-02-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
949 1ae0a341 2020-02-14 stsp if [ "$ret" != "0" ]; then
950 1ae0a341 2020-02-14 stsp diff -u $testroot/stdout.expected $testroot/stdout
952 1ae0a341 2020-02-14 stsp test_done "$testroot" "$ret"
955 1ae0a341 2020-02-14 stsp function test_rebase_trims_empty_dir {
956 1ae0a341 2020-02-14 stsp local testroot=`test_init rebase_trims_empty_dir`
958 1ae0a341 2020-02-14 stsp (cd $testroot/repo && git checkout -q -b newbranch)
959 1ae0a341 2020-02-14 stsp echo "modified delta on branch" > $testroot/repo/gamma/delta
960 1ae0a341 2020-02-14 stsp git_commit $testroot/repo -m "committing to delta on newbranch"
962 1ae0a341 2020-02-14 stsp (cd $testroot/repo && git rm -q epsilon/zeta)
963 1ae0a341 2020-02-14 stsp git_commit $testroot/repo -m "removing zeta on newbranch"
965 1ae0a341 2020-02-14 stsp local orig_commit1=`git_show_parent_commit $testroot/repo`
966 1ae0a341 2020-02-14 stsp local orig_commit2=`git_show_head $testroot/repo`
968 1ae0a341 2020-02-14 stsp (cd $testroot/repo && git checkout -q master)
969 1ae0a341 2020-02-14 stsp echo "modified alpha on master" > $testroot/repo/alpha
970 1ae0a341 2020-02-14 stsp git_commit $testroot/repo -m "committing to alpha on master"
971 1ae0a341 2020-02-14 stsp local master_commit=`git_show_head $testroot/repo`
973 1ae0a341 2020-02-14 stsp got checkout $testroot/repo $testroot/wt > /dev/null
975 1ae0a341 2020-02-14 stsp if [ "$ret" != "0" ]; then
976 1ae0a341 2020-02-14 stsp test_done "$testroot" "$ret"
980 1ae0a341 2020-02-14 stsp (cd $testroot/wt && got rebase newbranch > $testroot/stdout)
982 1ae0a341 2020-02-14 stsp (cd $testroot/repo && git checkout -q newbranch)
983 1ae0a341 2020-02-14 stsp local new_commit1=`git_show_parent_commit $testroot/repo`
984 1ae0a341 2020-02-14 stsp local new_commit2=`git_show_head $testroot/repo`
986 1ae0a341 2020-02-14 stsp local short_orig_commit1=`trim_obj_id 28 $orig_commit1`
987 1ae0a341 2020-02-14 stsp local short_orig_commit2=`trim_obj_id 28 $orig_commit2`
988 1ae0a341 2020-02-14 stsp local short_new_commit1=`trim_obj_id 28 $new_commit1`
989 1ae0a341 2020-02-14 stsp local short_new_commit2=`trim_obj_id 28 $new_commit2`
991 1ae0a341 2020-02-14 stsp echo "G gamma/delta" >> $testroot/stdout.expected
992 1ae0a341 2020-02-14 stsp echo -n "$short_orig_commit1 -> $short_new_commit1" \
993 1ae0a341 2020-02-14 stsp >> $testroot/stdout.expected
994 1ae0a341 2020-02-14 stsp echo ": committing to delta on newbranch" >> $testroot/stdout.expected
995 1ae0a341 2020-02-14 stsp echo "D epsilon/zeta" >> $testroot/stdout.expected
996 1ae0a341 2020-02-14 stsp echo -n "$short_orig_commit2 -> $short_new_commit2" \
997 1ae0a341 2020-02-14 stsp >> $testroot/stdout.expected
998 1ae0a341 2020-02-14 stsp echo ": removing zeta on newbranch" \
999 1ae0a341 2020-02-14 stsp >> $testroot/stdout.expected
1000 1ae0a341 2020-02-14 stsp echo "Switching work tree to refs/heads/newbranch" \
1001 1ae0a341 2020-02-14 stsp >> $testroot/stdout.expected
1003 e51d7b55 2020-01-04 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1005 e51d7b55 2020-01-04 stsp if [ "$ret" != "0" ]; then
1006 e51d7b55 2020-01-04 stsp diff -u $testroot/stdout.expected $testroot/stdout
1007 1ae0a341 2020-02-14 stsp test_done "$testroot" "$ret"
1011 1ae0a341 2020-02-14 stsp echo "modified delta on branch" > $testroot/content.expected
1012 1ae0a341 2020-02-14 stsp cat $testroot/wt/gamma/delta > $testroot/content
1013 1ae0a341 2020-02-14 stsp cmp -s $testroot/content.expected $testroot/content
1015 1ae0a341 2020-02-14 stsp if [ "$ret" != "0" ]; then
1016 1ae0a341 2020-02-14 stsp diff -u $testroot/content.expected $testroot/content
1017 1ae0a341 2020-02-14 stsp test_done "$testroot" "$ret"
1021 1ae0a341 2020-02-14 stsp echo "modified alpha on master" > $testroot/content.expected
1022 1ae0a341 2020-02-14 stsp cat $testroot/wt/alpha > $testroot/content
1023 1ae0a341 2020-02-14 stsp cmp -s $testroot/content.expected $testroot/content
1025 1ae0a341 2020-02-14 stsp if [ "$ret" != "0" ]; then
1026 1ae0a341 2020-02-14 stsp diff -u $testroot/content.expected $testroot/content
1027 1ae0a341 2020-02-14 stsp test_done "$testroot" "$ret"
1031 1ae0a341 2020-02-14 stsp if [ -e $testroot/wt/epsilon ]; then
1032 1ae0a341 2020-02-14 stsp echo "parent of removed zeta still exists on disk" >&2
1033 1ae0a341 2020-02-14 stsp test_done "$testroot" "1"
1037 1ae0a341 2020-02-14 stsp (cd $testroot/wt && got status > $testroot/stdout)
1039 1ae0a341 2020-02-14 stsp echo -n > $testroot/stdout.expected
1040 1ae0a341 2020-02-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1042 1ae0a341 2020-02-14 stsp if [ "$ret" != "0" ]; then
1043 1ae0a341 2020-02-14 stsp diff -u $testroot/stdout.expected $testroot/stdout
1044 1ae0a341 2020-02-14 stsp test_done "$testroot" "$ret"
1048 1ae0a341 2020-02-14 stsp (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
1049 1ae0a341 2020-02-14 stsp echo "commit $new_commit2 (newbranch)" > $testroot/stdout.expected
1050 1ae0a341 2020-02-14 stsp echo "commit $new_commit1" >> $testroot/stdout.expected
1051 1ae0a341 2020-02-14 stsp echo "commit $master_commit (master)" >> $testroot/stdout.expected
1052 1ae0a341 2020-02-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1054 1ae0a341 2020-02-14 stsp if [ "$ret" != "0" ]; then
1055 1ae0a341 2020-02-14 stsp diff -u $testroot/stdout.expected $testroot/stdout
1057 e51d7b55 2020-01-04 stsp test_done "$testroot" "$ret"
1060 dcf44d04 2019-07-11 stsp run_test test_rebase_basic
1061 dcf44d04 2019-07-11 stsp run_test test_rebase_ancestry_check
1062 dcf44d04 2019-07-11 stsp run_test test_rebase_continue
1063 dcf44d04 2019-07-11 stsp run_test test_rebase_abort
1064 ff0d2220 2019-07-11 stsp run_test test_rebase_no_op_change
1065 7d5807f4 2019-07-11 stsp run_test test_rebase_in_progress
1066 64c6d990 2019-07-11 stsp run_test test_rebase_path_prefix
1067 787c8eb6 2019-07-11 stsp run_test test_rebase_preserves_logmsg
1068 fc66b545 2019-08-12 stsp run_test test_rebase_no_commits_to_rebase
1069 38b0338b 2019-11-29 stsp run_test test_rebase_forward
1070 e51d7b55 2020-01-04 stsp run_test test_rebase_out_of_date
1071 1ae0a341 2020-02-14 stsp run_test test_rebase_trims_empty_dir