3 # Copyright (c) 2019, 2020 Stefan Sperling <stsp@openbsd.org>
5 # Permission to use, copy, modify, and distribute this software for any
6 # purpose with or without fee is hereby granted, provided that the above
7 # copyright notice and this permission notice appear in all copies.
9 # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
20 local testroot=`test_init rebase_basic`
21 local commit0=`git_show_head $testroot/repo`
22 local commit0_author_time=`git_show_author_time $testroot/repo`
24 (cd $testroot/repo && git checkout -q -b newbranch)
25 echo "modified delta on branch" > $testroot/repo/gamma/delta
26 git_commit $testroot/repo -m "committing to delta on newbranch"
28 echo "modified alpha on branch" > $testroot/repo/alpha
29 (cd $testroot/repo && git rm -q beta)
30 echo "new file on branch" > $testroot/repo/epsilon/new
31 (cd $testroot/repo && git add epsilon/new)
32 git_commit $testroot/repo -m "committing more changes on newbranch"
34 local orig_commit1=`git_show_parent_commit $testroot/repo`
35 local orig_commit2=`git_show_head $testroot/repo`
36 local orig_author_time2=`git_show_author_time $testroot/repo`
38 (cd $testroot/repo && git checkout -q master)
39 echo "modified zeta on master" > $testroot/repo/epsilon/zeta
40 git_commit $testroot/repo -m "committing to zeta on master"
41 local master_commit=`git_show_head $testroot/repo`
43 got checkout $testroot/repo $testroot/wt > /dev/null
45 if [ "$ret" != "0" ]; then
46 test_done "$testroot" "$ret"
50 (cd $testroot/wt && got rebase newbranch > $testroot/stdout)
52 (cd $testroot/repo && git checkout -q newbranch)
53 local new_commit1=`git_show_parent_commit $testroot/repo`
54 local new_commit2=`git_show_head $testroot/repo`
55 local new_author_time2=`git_show_author_time $testroot/repo`
57 local short_orig_commit1=`trim_obj_id 28 $orig_commit1`
58 local short_orig_commit2=`trim_obj_id 28 $orig_commit2`
59 local short_new_commit1=`trim_obj_id 28 $new_commit1`
60 local short_new_commit2=`trim_obj_id 28 $new_commit2`
62 echo "G gamma/delta" >> $testroot/stdout.expected
63 echo -n "$short_orig_commit1 -> $short_new_commit1" \
64 >> $testroot/stdout.expected
65 echo ": committing to delta on newbranch" >> $testroot/stdout.expected
66 echo "G alpha" >> $testroot/stdout.expected
67 echo "D beta" >> $testroot/stdout.expected
68 echo "A epsilon/new" >> $testroot/stdout.expected
69 echo -n "$short_orig_commit2 -> $short_new_commit2" \
70 >> $testroot/stdout.expected
71 echo ": committing more changes on newbranch" \
72 >> $testroot/stdout.expected
73 echo "Switching work tree to refs/heads/newbranch" \
74 >> $testroot/stdout.expected
76 cmp -s $testroot/stdout.expected $testroot/stdout
78 if [ "$ret" != "0" ]; then
79 diff -u $testroot/stdout.expected $testroot/stdout
80 test_done "$testroot" "$ret"
84 echo "modified delta on branch" > $testroot/content.expected
85 cat $testroot/wt/gamma/delta > $testroot/content
86 cmp -s $testroot/content.expected $testroot/content
88 if [ "$ret" != "0" ]; then
89 diff -u $testroot/content.expected $testroot/content
90 test_done "$testroot" "$ret"
94 echo "modified alpha on branch" > $testroot/content.expected
95 cat $testroot/wt/alpha > $testroot/content
96 cmp -s $testroot/content.expected $testroot/content
98 if [ "$ret" != "0" ]; then
99 diff -u $testroot/content.expected $testroot/content
100 test_done "$testroot" "$ret"
104 if [ -e $testroot/wt/beta ]; then
105 echo "removed file beta still exists on disk" >&2
106 test_done "$testroot" "1"
110 echo "new file on branch" > $testroot/content.expected
111 cat $testroot/wt/epsilon/new > $testroot/content
112 cmp -s $testroot/content.expected $testroot/content
114 if [ "$ret" != "0" ]; then
115 diff -u $testroot/content.expected $testroot/content
116 test_done "$testroot" "$ret"
120 (cd $testroot/wt && got status > $testroot/stdout)
122 echo -n > $testroot/stdout.expected
123 cmp -s $testroot/stdout.expected $testroot/stdout
125 if [ "$ret" != "0" ]; then
126 diff -u $testroot/stdout.expected $testroot/stdout
127 test_done "$testroot" "$ret"
131 (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
132 echo "commit $new_commit2 (newbranch)" > $testroot/stdout.expected
133 echo "commit $new_commit1" >> $testroot/stdout.expected
134 echo "commit $master_commit (master)" >> $testroot/stdout.expected
135 cmp -s $testroot/stdout.expected $testroot/stdout
137 if [ "$ret" != "0" ]; then
138 diff -u $testroot/stdout.expected $testroot/stdout
139 test_done "$testroot" "$ret"
143 (cd $testroot/wt && got update > $testroot/stdout)
145 echo 'Already up-to-date' > $testroot/stdout.expected
146 cmp -s $testroot/stdout.expected $testroot/stdout
148 if [ "$ret" != "0" ]; then
149 diff -u $testroot/stdout.expected $testroot/stdout
150 test_done "$testroot" "$ret"
153 # We should have a backup of old commits
154 (cd $testroot/repo && got rebase -l > $testroot/stdout)
155 d_orig2=`env TZ=UTC date -r $orig_author_time2 +"%a %b %e %X %Y UTC"`
156 d_new2=`env TZ=UTC date -r $new_author_time2 +"%G-%m-%d"`
157 d_0=`env TZ=UTC date -r $commit0_author_time +"%G-%m-%d"`
158 cat > $testroot/stdout.expected <<EOF
159 -----------------------------------------------
160 commit $orig_commit2 (formerly newbranch)
164 committing more changes on newbranch
166 has become commit $new_commit2 (newbranch)
167 $d_new2 $GOT_AUTHOR_11 committing more changes on newbranch
168 history forked at $commit0
169 $d_0 $GOT_AUTHOR_11 adding the test tree
171 cmp -s $testroot/stdout.expected $testroot/stdout
173 if [ "$ret" != "0" ]; then
174 diff -u $testroot/stdout.expected $testroot/stdout
175 test_done "$testroot" "$ret"
178 # Asking for backups of a branch which has none should yield an error
179 (cd $testroot/repo && got rebase -l master \
180 > $testroot/stdout 2> $testroot/stderr)
181 echo -n > $testroot/stdout.expected
182 echo "got: refs/got/backup/rebase/master/: no such reference found" \
183 > $testroot/stderr.expected
184 cmp -s $testroot/stdout.expected $testroot/stdout
186 if [ "$ret" != "0" ]; then
187 diff -u $testroot/stdout.expected $testroot/stdout
188 test_done "$testroot" "$ret"
191 cmp -s $testroot/stderr.expected $testroot/stderr
193 if [ "$ret" != "0" ]; then
194 diff -u $testroot/stderr.expected $testroot/stderr
195 test_done "$testroot" "$ret"
199 # Delete all backup refs
200 (cd $testroot/repo && got rebase -X \
201 > $testroot/stdout 2> $testroot/stderr)
202 echo -n "Deleted refs/got/backup/rebase/newbranch/$new_commit2: " \
203 > $testroot/stdout.expected
204 echo "$orig_commit2" >> $testroot/stdout.expected
205 echo -n > $testroot/stderr.expected
206 cmp -s $testroot/stdout.expected $testroot/stdout
208 if [ "$ret" != "0" ]; then
209 diff -u $testroot/stdout.expected $testroot/stdout
210 test_done "$testroot" "$ret"
213 cmp -s $testroot/stderr.expected $testroot/stderr
215 if [ "$ret" != "0" ]; then
216 diff -u $testroot/stderr.expected $testroot/stderr
217 test_done "$testroot" "$ret"
221 (cd $testroot/repo && got rebase -l > $testroot/stdout)
222 echo -n > $testroot/stdout.expected
223 cmp -s $testroot/stdout.expected $testroot/stdout
225 if [ "$ret" != "0" ]; then
226 diff -u $testroot/stdout.expected $testroot/stdout
228 test_done "$testroot" "$ret"
231 test_rebase_ancestry_check() {
232 local testroot=`test_init rebase_ancestry_check`
234 got checkout $testroot/repo $testroot/wt > /dev/null
236 if [ "$ret" != "0" ]; then
237 test_done "$testroot" "$ret"
241 (cd $testroot/repo && git checkout -q -b newbranch)
242 echo "modified delta on branch" > $testroot/repo/gamma/delta
243 git_commit $testroot/repo -m "committing to delta on newbranch"
245 (cd $testroot/wt && got rebase newbranch > $testroot/stdout \
248 echo -n > $testroot/stdout.expected
249 cmp -s $testroot/stdout.expected $testroot/stdout
251 if [ "$ret" != "0" ]; then
252 diff -u $testroot/stdout.expected $testroot/stdout
253 test_done "$testroot" "$ret"
257 echo "got: refs/heads/newbranch is already based on refs/heads/master" \
258 > $testroot/stderr.expected
259 cmp -s $testroot/stderr.expected $testroot/stderr
261 if [ "$ret" != "0" ]; then
262 diff -u $testroot/stderr.expected $testroot/stderr
264 test_done "$testroot" "$ret"
267 test_rebase_continue() {
268 local testroot=`test_init rebase_continue`
269 local init_commit=`git_show_head $testroot/repo`
271 (cd $testroot/repo && git checkout -q -b newbranch)
272 echo "modified alpha on branch" > $testroot/repo/alpha
273 git_commit $testroot/repo -m "committing to alpha on newbranch"
274 local orig_commit1=`git_show_head $testroot/repo`
275 local short_orig_commit1=`trim_obj_id 28 $orig_commit1`
277 (cd $testroot/repo && git checkout -q master)
278 echo "modified alpha on master" > $testroot/repo/alpha
279 git_commit $testroot/repo -m "committing to alpha on master"
280 local master_commit=`git_show_head $testroot/repo`
282 got checkout $testroot/repo $testroot/wt > /dev/null
284 if [ "$ret" != "0" ]; then
285 test_done "$testroot" "$ret"
289 (cd $testroot/wt && got rebase newbranch > $testroot/stdout \
292 echo "C alpha" > $testroot/stdout.expected
293 echo "Files with new merge conflicts: 1" >> $testroot/stdout.expected
294 echo -n "$short_orig_commit1 -> merge conflict" \
295 >> $testroot/stdout.expected
296 echo ": committing to alpha on newbranch" >> $testroot/stdout.expected
297 cmp -s $testroot/stdout.expected $testroot/stdout
299 if [ "$ret" != "0" ]; then
300 diff -u $testroot/stdout.expected $testroot/stdout
301 test_done "$testroot" "$ret"
305 echo "got: conflicts must be resolved before rebasing can continue" \
306 > $testroot/stderr.expected
307 cmp -s $testroot/stderr.expected $testroot/stderr
309 if [ "$ret" != "0" ]; then
310 diff -u $testroot/stderr.expected $testroot/stderr
311 test_done "$testroot" "$ret"
315 echo '<<<<<<<' > $testroot/content.expected
316 echo "modified alpha on master" >> $testroot/content.expected
317 echo "||||||| 3-way merge base: commit $init_commit" \
318 >> $testroot/content.expected
319 echo "alpha" >> $testroot/content.expected
320 echo "=======" >> $testroot/content.expected
321 echo "modified alpha on branch" >> $testroot/content.expected
322 echo ">>>>>>> merged change: commit $orig_commit1" \
323 >> $testroot/content.expected
324 cat $testroot/wt/alpha > $testroot/content
325 cmp -s $testroot/content.expected $testroot/content
327 if [ "$ret" != "0" ]; then
328 diff -u $testroot/content.expected $testroot/content
329 test_done "$testroot" "$ret"
333 (cd $testroot/wt && got status > $testroot/stdout)
335 echo "C alpha" > $testroot/stdout.expected
336 cmp -s $testroot/stdout.expected $testroot/stdout
338 if [ "$ret" != "0" ]; then
339 diff -u $testroot/stdout.expected $testroot/stdout
340 test_done "$testroot" "$ret"
344 # resolve the conflict
345 echo "modified alpha on branch and master" > $testroot/wt/alpha
347 # test interaction of 'got stage' and rebase -c
348 (cd $testroot/wt && got stage alpha > /dev/null)
349 (cd $testroot/wt && got rebase -c > $testroot/stdout \
352 if [ "$ret" = "0" ]; then
353 echo "rebase succeeded unexpectedly" >&2
354 test_done "$testroot" "1"
357 echo -n "got: work tree contains files with staged changes; " \
358 > $testroot/stderr.expected
359 echo "these changes must be committed or unstaged first" \
360 >> $testroot/stderr.expected
361 cmp -s $testroot/stderr.expected $testroot/stderr
363 if [ "$ret" != "0" ]; then
364 diff -u $testroot/stderr.expected $testroot/stderr
365 test_done "$testroot" "$ret"
369 (cd $testroot/wt && got unstage alpha > /dev/null)
370 (cd $testroot/wt && got rebase -c > $testroot/stdout)
372 (cd $testroot/repo && git checkout -q newbranch)
373 local new_commit1=`git_show_head $testroot/repo`
374 local short_new_commit1=`trim_obj_id 28 $new_commit1`
376 echo -n "$short_orig_commit1 -> $short_new_commit1" \
377 > $testroot/stdout.expected
378 echo ": committing to alpha on newbranch" >> $testroot/stdout.expected
379 echo "Switching work tree to refs/heads/newbranch" \
380 >> $testroot/stdout.expected
382 cmp -s $testroot/stdout.expected $testroot/stdout
384 if [ "$ret" != "0" ]; then
385 diff -u $testroot/stdout.expected $testroot/stdout
386 test_done "$testroot" "$ret"
391 (cd $testroot/wt && got log -l2 | grep ^commit > $testroot/stdout)
392 echo "commit $new_commit1 (newbranch)" > $testroot/stdout.expected
393 echo "commit $master_commit (master)" >> $testroot/stdout.expected
394 cmp -s $testroot/stdout.expected $testroot/stdout
396 if [ "$ret" != "0" ]; then
397 diff -u $testroot/stdout.expected $testroot/stdout
399 test_done "$testroot" "$ret"
402 test_rebase_abort() {
403 local testroot=`test_init rebase_abort`
405 local init_commit=`git_show_head $testroot/repo`
407 (cd $testroot/repo && git checkout -q -b newbranch)
408 echo "modified alpha on branch" > $testroot/repo/alpha
409 git_commit $testroot/repo -m "committing to alpha on newbranch"
410 local orig_commit1=`git_show_head $testroot/repo`
411 local short_orig_commit1=`trim_obj_id 28 $orig_commit1`
413 (cd $testroot/repo && git checkout -q master)
414 echo "modified alpha on master" > $testroot/repo/alpha
415 git_commit $testroot/repo -m "committing to alpha on master"
416 local master_commit=`git_show_head $testroot/repo`
418 got checkout $testroot/repo $testroot/wt > /dev/null
420 if [ "$ret" != "0" ]; then
421 test_done "$testroot" "$ret"
425 (cd $testroot/wt && got rebase newbranch > $testroot/stdout \
428 echo "C alpha" > $testroot/stdout.expected
429 echo "Files with new merge conflicts: 1" >> $testroot/stdout.expected
430 echo -n "$short_orig_commit1 -> merge conflict" \
431 >> $testroot/stdout.expected
432 echo ": committing to alpha on newbranch" >> $testroot/stdout.expected
433 cmp -s $testroot/stdout.expected $testroot/stdout
435 if [ "$ret" != "0" ]; then
436 diff -u $testroot/stdout.expected $testroot/stdout
437 test_done "$testroot" "$ret"
441 echo "got: conflicts must be resolved before rebasing can continue" \
442 > $testroot/stderr.expected
443 cmp -s $testroot/stderr.expected $testroot/stderr
445 if [ "$ret" != "0" ]; then
446 diff -u $testroot/stderr.expected $testroot/stderr
447 test_done "$testroot" "$ret"
451 echo '<<<<<<<' > $testroot/content.expected
452 echo "modified alpha on master" >> $testroot/content.expected
453 echo "||||||| 3-way merge base: commit $init_commit" \
454 >> $testroot/content.expected
455 echo "alpha" >> $testroot/content.expected
456 echo "=======" >> $testroot/content.expected
457 echo "modified alpha on branch" >> $testroot/content.expected
458 echo ">>>>>>> merged change: commit $orig_commit1" \
459 >> $testroot/content.expected
460 cat $testroot/wt/alpha > $testroot/content
461 cmp -s $testroot/content.expected $testroot/content
463 if [ "$ret" != "0" ]; then
464 diff -u $testroot/content.expected $testroot/content
465 test_done "$testroot" "$ret"
469 (cd $testroot/wt && got status > $testroot/stdout)
471 echo "C alpha" > $testroot/stdout.expected
472 cmp -s $testroot/stdout.expected $testroot/stdout
474 if [ "$ret" != "0" ]; then
475 diff -u $testroot/stdout.expected $testroot/stdout
476 test_done "$testroot" "$ret"
480 (cd $testroot/wt && got rebase -a > $testroot/stdout)
482 (cd $testroot/repo && git checkout -q newbranch)
484 echo "Switching work tree to refs/heads/master" \
485 > $testroot/stdout.expected
486 echo 'R alpha' >> $testroot/stdout.expected
487 echo "Rebase of refs/heads/newbranch aborted" \
488 >> $testroot/stdout.expected
490 cmp -s $testroot/stdout.expected $testroot/stdout
492 if [ "$ret" != "0" ]; then
493 diff -u $testroot/stdout.expected $testroot/stdout
494 test_done "$testroot" "$ret"
498 echo "modified alpha on master" > $testroot/content.expected
499 cat $testroot/wt/alpha > $testroot/content
500 cmp -s $testroot/content.expected $testroot/content
502 if [ "$ret" != "0" ]; then
503 diff -u $testroot/content.expected $testroot/content
504 test_done "$testroot" "$ret"
508 (cd $testroot/wt && got log -l3 -c newbranch \
509 | grep ^commit > $testroot/stdout)
510 echo "commit $orig_commit1 (newbranch)" > $testroot/stdout.expected
511 echo "commit $init_commit" >> $testroot/stdout.expected
512 cmp -s $testroot/stdout.expected $testroot/stdout
514 if [ "$ret" != "0" ]; then
515 diff -u $testroot/stdout.expected $testroot/stdout
517 test_done "$testroot" "$ret"
520 test_rebase_no_op_change() {
521 local testroot=`test_init rebase_no_op_change`
522 local init_commit=`git_show_head $testroot/repo`
524 (cd $testroot/repo && git checkout -q -b newbranch)
525 echo "modified alpha on branch" > $testroot/repo/alpha
526 git_commit $testroot/repo -m "committing to alpha on newbranch"
527 local orig_commit1=`git_show_head $testroot/repo`
528 local short_orig_commit1=`trim_obj_id 28 $orig_commit1`
530 (cd $testroot/repo && git checkout -q master)
531 echo "modified alpha on master" > $testroot/repo/alpha
532 git_commit $testroot/repo -m "committing to alpha on master"
533 local master_commit=`git_show_head $testroot/repo`
535 got checkout $testroot/repo $testroot/wt > /dev/null
537 if [ "$ret" != "0" ]; then
538 test_done "$testroot" "$ret"
542 (cd $testroot/wt && got rebase newbranch > $testroot/stdout \
545 echo "C alpha" > $testroot/stdout.expected
546 echo "Files with new merge conflicts: 1" >> $testroot/stdout.expected
547 echo -n "$short_orig_commit1 -> merge conflict" \
548 >> $testroot/stdout.expected
549 echo ": committing to alpha on newbranch" >> $testroot/stdout.expected
550 cmp -s $testroot/stdout.expected $testroot/stdout
552 if [ "$ret" != "0" ]; then
553 diff -u $testroot/stdout.expected $testroot/stdout
554 test_done "$testroot" "$ret"
558 echo "got: conflicts must be resolved before rebasing can continue" \
559 > $testroot/stderr.expected
560 cmp -s $testroot/stderr.expected $testroot/stderr
562 if [ "$ret" != "0" ]; then
563 diff -u $testroot/stderr.expected $testroot/stderr
564 test_done "$testroot" "$ret"
568 echo '<<<<<<<' > $testroot/content.expected
569 echo "modified alpha on master" >> $testroot/content.expected
570 echo "||||||| 3-way merge base: commit $init_commit" \
571 >> $testroot/content.expected
572 echo "alpha" >> $testroot/content.expected
573 echo "=======" >> $testroot/content.expected
574 echo "modified alpha on branch" >> $testroot/content.expected
575 echo ">>>>>>> merged change: commit $orig_commit1" \
576 >> $testroot/content.expected
577 cat $testroot/wt/alpha > $testroot/content
578 cmp -s $testroot/content.expected $testroot/content
580 if [ "$ret" != "0" ]; then
581 diff -u $testroot/content.expected $testroot/content
582 test_done "$testroot" "$ret"
586 (cd $testroot/wt && got status > $testroot/stdout)
588 echo "C alpha" > $testroot/stdout.expected
589 cmp -s $testroot/stdout.expected $testroot/stdout
591 if [ "$ret" != "0" ]; then
592 diff -u $testroot/stdout.expected $testroot/stdout
593 test_done "$testroot" "$ret"
597 # resolve the conflict
598 echo "modified alpha on master" > $testroot/wt/alpha
600 (cd $testroot/wt && got rebase -c > $testroot/stdout)
602 (cd $testroot/repo && git checkout -q newbranch)
603 local new_commit1=`git_show_head $testroot/repo`
605 echo -n "$short_orig_commit1 -> no-op change" \
606 > $testroot/stdout.expected
607 echo ": committing to alpha on newbranch" >> $testroot/stdout.expected
608 echo "Switching work tree to refs/heads/newbranch" \
609 >> $testroot/stdout.expected
611 cmp -s $testroot/stdout.expected $testroot/stdout
613 if [ "$ret" != "0" ]; then
614 diff -u $testroot/stdout.expected $testroot/stdout
615 test_done "$testroot" "$ret"
620 (cd $testroot/wt && got log -l2 | grep ^commit > $testroot/stdout)
621 echo "commit $master_commit (master, newbranch)" \
622 > $testroot/stdout.expected
623 echo "commit $init_commit" >> $testroot/stdout.expected
624 cmp -s $testroot/stdout.expected $testroot/stdout
626 if [ "$ret" != "0" ]; then
627 diff -u $testroot/stdout.expected $testroot/stdout
629 test_done "$testroot" "$ret"
632 test_rebase_in_progress() {
633 local testroot=`test_init rebase_in_progress`
634 local init_commit=`git_show_head $testroot/repo`
636 (cd $testroot/repo && git checkout -q -b newbranch)
637 echo "modified alpha on branch" > $testroot/repo/alpha
638 git_commit $testroot/repo -m "committing to alpha on newbranch"
639 local orig_commit1=`git_show_head $testroot/repo`
640 local short_orig_commit1=`trim_obj_id 28 $orig_commit1`
642 (cd $testroot/repo && git checkout -q master)
643 echo "modified alpha on master" > $testroot/repo/alpha
644 git_commit $testroot/repo -m "committing to alpha on master"
645 local master_commit=`git_show_head $testroot/repo`
647 got checkout $testroot/repo $testroot/wt > /dev/null
649 if [ "$ret" != "0" ]; then
650 test_done "$testroot" "$ret"
654 (cd $testroot/wt && got rebase newbranch > $testroot/stdout \
657 echo "C alpha" > $testroot/stdout.expected
658 echo "Files with new merge conflicts: 1" >> $testroot/stdout.expected
659 echo -n "$short_orig_commit1 -> merge conflict" \
660 >> $testroot/stdout.expected
661 echo ": committing to alpha on newbranch" >> $testroot/stdout.expected
662 cmp -s $testroot/stdout.expected $testroot/stdout
664 if [ "$ret" != "0" ]; then
665 diff -u $testroot/stdout.expected $testroot/stdout
666 test_done "$testroot" "$ret"
670 echo "got: conflicts must be resolved before rebasing can continue" \
671 > $testroot/stderr.expected
672 cmp -s $testroot/stderr.expected $testroot/stderr
674 if [ "$ret" != "0" ]; then
675 diff -u $testroot/stderr.expected $testroot/stderr
676 test_done "$testroot" "$ret"
680 echo '<<<<<<<' > $testroot/content.expected
681 echo "modified alpha on master" >> $testroot/content.expected
682 echo "||||||| 3-way merge base: commit $init_commit" \
683 >> $testroot/content.expected
684 echo "alpha" >> $testroot/content.expected
685 echo "=======" >> $testroot/content.expected
686 echo "modified alpha on branch" >> $testroot/content.expected
687 echo ">>>>>>> merged change: commit $orig_commit1" \
688 >> $testroot/content.expected
689 cat $testroot/wt/alpha > $testroot/content
690 cmp -s $testroot/content.expected $testroot/content
692 if [ "$ret" != "0" ]; then
693 diff -u $testroot/content.expected $testroot/content
694 test_done "$testroot" "$ret"
698 (cd $testroot/wt && got status > $testroot/stdout)
700 echo "C alpha" > $testroot/stdout.expected
701 cmp -s $testroot/stdout.expected $testroot/stdout
703 if [ "$ret" != "0" ]; then
704 diff -u $testroot/stdout.expected $testroot/stdout
705 test_done "$testroot" "$ret"
709 for cmd in update commit; do
710 (cd $testroot/wt && got $cmd > $testroot/stdout \
713 echo -n > $testroot/stdout.expected
714 cmp -s $testroot/stdout.expected $testroot/stdout
716 if [ "$ret" != "0" ]; then
717 diff -u $testroot/stdout.expected $testroot/stdout
718 test_done "$testroot" "$ret"
722 echo -n "got: a rebase operation is in progress in this " \
723 > $testroot/stderr.expected
724 echo "work tree and must be continued or aborted first" \
725 >> $testroot/stderr.expected
726 cmp -s $testroot/stderr.expected $testroot/stderr
728 if [ "$ret" != "0" ]; then
729 diff -u $testroot/stderr.expected $testroot/stderr
730 test_done "$testroot" "$ret"
735 test_done "$testroot" "$ret"
738 test_rebase_path_prefix() {
739 local testroot=`test_init rebase_path_prefix`
741 (cd $testroot/repo && git checkout -q -b newbranch)
742 echo "modified delta on branch" > $testroot/repo/gamma/delta
743 git_commit $testroot/repo -m "committing to delta on newbranch"
745 local orig_commit1=`git_show_parent_commit $testroot/repo`
746 local orig_commit2=`git_show_head $testroot/repo`
748 (cd $testroot/repo && git checkout -q master)
749 echo "modified zeta on master" > $testroot/repo/epsilon/zeta
750 git_commit $testroot/repo -m "committing to zeta on master"
751 local master_commit=`git_show_head $testroot/repo`
753 got checkout -p epsilon $testroot/repo $testroot/wt > /dev/null
755 if [ "$ret" != "0" ]; then
756 test_done "$testroot" "$ret"
760 (cd $testroot/wt && got rebase newbranch \
761 > $testroot/stdout 2> $testroot/stderr)
763 echo -n > $testroot/stdout.expected
764 cmp -s $testroot/stdout.expected $testroot/stdout
766 if [ "$ret" != "0" ]; then
767 diff -u $testroot/stdout.expected $testroot/stdout
768 test_done "$testroot" "$ret"
772 echo -n "got: cannot rebase branch which contains changes outside " \
773 > $testroot/stderr.expected
774 echo "of this work tree's path prefix" >> $testroot/stderr.expected
775 cmp -s $testroot/stderr.expected $testroot/stderr
777 if [ "$ret" != "0" ]; then
778 diff -u $testroot/stderr.expected $testroot/stderr
780 test_done "$testroot" "$ret"
783 test_rebase_preserves_logmsg() {
784 local testroot=`test_init rebase_preserves_logmsg`
786 (cd $testroot/repo && git checkout -q -b newbranch)
787 echo "modified delta on branch" > $testroot/repo/gamma/delta
788 git_commit $testroot/repo -m "modified delta on newbranch"
790 echo "modified alpha on branch" > $testroot/repo/alpha
791 git_commit $testroot/repo -m "modified alpha on newbranch"
793 (cd $testroot/repo && got log -c newbranch -l2 | grep -v ^date: \
794 > $testroot/log.expected)
796 local orig_commit1=`git_show_parent_commit $testroot/repo`
797 local orig_commit2=`git_show_head $testroot/repo`
799 (cd $testroot/repo && git checkout -q master)
800 echo "modified zeta on master" > $testroot/repo/epsilon/zeta
801 git_commit $testroot/repo -m "committing to zeta on master"
802 local master_commit=`git_show_head $testroot/repo`
804 got checkout $testroot/repo $testroot/wt > /dev/null
806 if [ "$ret" != "0" ]; then
807 test_done "$testroot" "$ret"
811 (cd $testroot/wt && got rebase newbranch > /dev/null \
814 (cd $testroot/repo && git checkout -q newbranch)
815 local new_commit1=`git_show_parent_commit $testroot/repo`
816 local new_commit2=`git_show_head $testroot/repo`
818 echo -n > $testroot/stderr.expected
819 cmp -s $testroot/stderr.expected $testroot/stderr
821 if [ "$ret" != "0" ]; then
822 diff -u $testroot/stderr.expected $testroot/stderr
823 test_done "$testroot" "$ret"
827 (cd $testroot/wt && got log -c newbranch -l2 | grep -v ^date: \
829 sed -i -e "s/$orig_commit1/$new_commit1/" $testroot/log.expected
830 sed -i -e "s/$orig_commit2/$new_commit2/" $testroot/log.expected
831 cmp -s $testroot/log.expected $testroot/log
833 if [ "$ret" != "0" ]; then
834 diff -u $testroot/log.expected $testroot/log
837 test_done "$testroot" "$ret"
840 test_rebase_no_commits_to_rebase() {
841 local testroot=`test_init rebase_no_commits_to_rebase`
843 got checkout $testroot/repo $testroot/wt > /dev/null
845 if [ "$ret" != "0" ]; then
846 test_done "$testroot" "$ret"
850 (cd $testroot/wt && got branch -n newbranch)
852 echo "modified alpha on master" > $testroot/wt/alpha
853 (cd $testroot/wt && got commit -m 'test rebase_no_commits_to_rebase' \
855 (cd $testroot/wt && got update > /dev/null)
857 (cd $testroot/wt && got rebase newbranch > $testroot/stdout \
860 echo "got: no commits to rebase" > $testroot/stderr.expected
861 cmp -s $testroot/stderr.expected $testroot/stderr
863 if [ "$ret" != "0" ]; then
864 diff -u $testroot/stderr.expected $testroot/stderr
865 test_done "$testroot" "$ret"
869 echo "Rebase of refs/heads/newbranch aborted" \
870 > $testroot/stdout.expected
871 cmp -s $testroot/stdout.expected $testroot/stdout
873 if [ "$ret" != "0" ]; then
874 diff -u $testroot/stdout.expected $testroot/stdout
875 test_done "$testroot" "$ret"
879 (cd $testroot/wt && got update > $testroot/stdout)
880 echo "Already up-to-date" > $testroot/stdout.expected
881 cmp -s $testroot/stdout.expected $testroot/stdout
883 if [ "$ret" != "0" ]; then
884 diff -u $testroot/stdout.expected $testroot/stdout
886 test_done "$testroot" "$ret"
889 test_rebase_forward() {
890 local testroot=`test_init rebase_forward`
891 local commit0=`git_show_head $testroot/repo`
893 got checkout $testroot/repo $testroot/wt > /dev/null
895 if [ "$ret" != "0" ]; then
896 test_done "$testroot" "$ret"
900 echo "change alpha 1" > $testroot/wt/alpha
901 (cd $testroot/wt && got commit -m 'test rebase_forward' \
903 local commit1=`git_show_head $testroot/repo`
905 echo "change alpha 2" > $testroot/wt/alpha
906 (cd $testroot/wt && got commit -m 'test rebase_forward' \
908 local commit2=`git_show_head $testroot/repo`
910 # Simulate a situation where fast-forward is required.
911 # We want to fast-forward master to origin/master:
912 # commit 3907e11dceaae2ca7f8db79c2af31794673945ad (origin/master)
913 # commit ffcffcd102cf1af6572fbdbb4cf07a0f1fd2d840 (master)
914 # commit 87a6a8a2263a15b61c016ff1720b24741d455eb5
915 (cd $testroot/repo && got ref -d master >/dev/null)
916 (cd $testroot/repo && got ref -c $commit1 refs/heads/master)
917 (cd $testroot/repo && got ref -c $commit2 refs/remotes/origin/master)
919 (cd $testroot/wt && got up -b origin/master > /dev/null)
921 (cd $testroot/wt && got rebase master \
922 > $testroot/stdout 2> $testroot/stderr)
924 echo "Forwarding refs/heads/master to commit $commit2" \
925 > $testroot/stdout.expected
926 echo "Switching work tree to refs/heads/master" \
927 >> $testroot/stdout.expected
928 cmp -s $testroot/stdout.expected $testroot/stdout
930 if [ "$ret" != "0" ]; then
931 diff -u $testroot/stdout.expected $testroot/stdout
932 test_done "$testroot" "$ret"
936 # Ensure that rebase operation was completed correctly
937 (cd $testroot/wt && got rebase -a \
938 > $testroot/stdout 2> $testroot/stderr)
939 echo -n "" > $testroot/stdout.expected
940 cmp -s $testroot/stdout.expected $testroot/stdout
942 if [ "$ret" != "0" ]; then
943 diff -u $testroot/stdout.expected $testroot/stdout
944 test_done "$testroot" "$ret"
947 echo "got: rebase operation not in progress" > $testroot/stderr.expected
948 cmp -s $testroot/stderr.expected $testroot/stderr
950 if [ "$ret" != "0" ]; then
951 diff -u $testroot/stderr.expected $testroot/stderr
952 test_done "$testroot" "$ret"
956 (cd $testroot/wt && got branch -n > $testroot/stdout)
957 echo "master" > $testroot/stdout.expected
958 cmp -s $testroot/stdout.expected $testroot/stdout
960 if [ "$ret" != "0" ]; then
961 diff -u $testroot/stdout.expected $testroot/stdout
962 test_done "$testroot" "$ret"
966 (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
967 echo "commit $commit2 (master, origin/master)" > $testroot/stdout.expected
968 echo "commit $commit1" >> $testroot/stdout.expected
969 echo "commit $commit0" >> $testroot/stdout.expected
970 cmp -s $testroot/stdout.expected $testroot/stdout
972 if [ "$ret" != "0" ]; then
973 diff -u $testroot/stdout.expected $testroot/stdout
974 test_done "$testroot" "$ret"
977 # Forward-only rebase operations should not be backed up
978 (cd $testroot/repo && got rebase -l > $testroot/stdout)
979 echo -n > $testroot/stdout.expected
980 cmp -s $testroot/stdout.expected $testroot/stdout
982 if [ "$ret" != "0" ]; then
983 diff -u $testroot/stdout.expected $testroot/stdout
985 test_done "$testroot" "$ret"
988 test_rebase_out_of_date() {
989 local testroot=`test_init rebase_out_of_date`
990 local initial_commit=`git_show_head $testroot/repo`
992 (cd $testroot/repo && git checkout -q -b newbranch)
993 echo "modified delta on branch" > $testroot/repo/gamma/delta
994 git_commit $testroot/repo -m "committing to delta on newbranch"
996 echo "modified alpha on branch" > $testroot/repo/alpha
997 (cd $testroot/repo && git rm -q beta)
998 echo "new file on branch" > $testroot/repo/epsilon/new
999 (cd $testroot/repo && git add epsilon/new)
1000 git_commit $testroot/repo -m "committing more changes on newbranch"
1002 local orig_commit1=`git_show_parent_commit $testroot/repo`
1003 local orig_commit2=`git_show_head $testroot/repo`
1005 (cd $testroot/repo && git checkout -q master)
1006 echo "modified zeta on master" > $testroot/repo/epsilon/zeta
1007 git_commit $testroot/repo -m "committing to zeta on master"
1008 local master_commit1=`git_show_head $testroot/repo`
1010 (cd $testroot/repo && git checkout -q master)
1011 echo "modified beta on master" > $testroot/repo/beta
1012 git_commit $testroot/repo -m "committing to beta on master"
1013 local master_commit2=`git_show_head $testroot/repo`
1015 got checkout -c $master_commit1 $testroot/repo $testroot/wt \
1018 if [ "$ret" != "0" ]; then
1019 test_done "$testroot" "$ret"
1023 (cd $testroot/wt && got rebase newbranch > $testroot/stdout \
1024 2> $testroot/stderr)
1026 echo -n > $testroot/stdout.expected
1027 cmp -s $testroot/stdout.expected $testroot/stdout
1029 if [ "$ret" != "0" ]; then
1030 diff -u $testroot/stdout.expected $testroot/stdout
1031 test_done "$testroot" "$ret"
1035 echo -n "got: work tree must be updated before it can be " \
1036 > $testroot/stderr.expected
1037 echo "used to rebase a branch" >> $testroot/stderr.expected
1038 cmp -s $testroot/stderr.expected $testroot/stderr
1040 if [ "$ret" != "0" ]; then
1041 diff -u $testroot/stderr.expected $testroot/stderr
1042 test_done "$testroot" "$ret"
1046 (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
1047 echo "commit $master_commit2 (master)" > $testroot/stdout.expected
1048 echo "commit $master_commit1" >> $testroot/stdout.expected
1049 echo "commit $initial_commit" >> $testroot/stdout.expected
1050 cmp -s $testroot/stdout.expected $testroot/stdout
1052 if [ "$ret" != "0" ]; then
1053 diff -u $testroot/stdout.expected $testroot/stdout
1055 test_done "$testroot" "$ret"
1058 test_rebase_trims_empty_dir() {
1059 local testroot=`test_init rebase_trims_empty_dir`
1061 (cd $testroot/repo && git checkout -q -b newbranch)
1062 echo "modified delta on branch" > $testroot/repo/gamma/delta
1063 git_commit $testroot/repo -m "committing to delta on newbranch"
1065 (cd $testroot/repo && git rm -q epsilon/zeta)
1066 git_commit $testroot/repo -m "removing zeta on newbranch"
1068 local orig_commit1=`git_show_parent_commit $testroot/repo`
1069 local orig_commit2=`git_show_head $testroot/repo`
1071 (cd $testroot/repo && git checkout -q master)
1072 echo "modified alpha on master" > $testroot/repo/alpha
1073 git_commit $testroot/repo -m "committing to alpha on master"
1074 local master_commit=`git_show_head $testroot/repo`
1076 got checkout $testroot/repo $testroot/wt > /dev/null
1078 if [ "$ret" != "0" ]; then
1079 test_done "$testroot" "$ret"
1083 (cd $testroot/wt && got rebase newbranch > $testroot/stdout)
1085 (cd $testroot/repo && git checkout -q newbranch)
1086 local new_commit1=`git_show_parent_commit $testroot/repo`
1087 local new_commit2=`git_show_head $testroot/repo`
1089 local short_orig_commit1=`trim_obj_id 28 $orig_commit1`
1090 local short_orig_commit2=`trim_obj_id 28 $orig_commit2`
1091 local short_new_commit1=`trim_obj_id 28 $new_commit1`
1092 local short_new_commit2=`trim_obj_id 28 $new_commit2`
1094 echo "G gamma/delta" >> $testroot/stdout.expected
1095 echo -n "$short_orig_commit1 -> $short_new_commit1" \
1096 >> $testroot/stdout.expected
1097 echo ": committing to delta on newbranch" >> $testroot/stdout.expected
1098 echo "D epsilon/zeta" >> $testroot/stdout.expected
1099 echo -n "$short_orig_commit2 -> $short_new_commit2" \
1100 >> $testroot/stdout.expected
1101 echo ": removing zeta on newbranch" \
1102 >> $testroot/stdout.expected
1103 echo "Switching work tree to refs/heads/newbranch" \
1104 >> $testroot/stdout.expected
1106 cmp -s $testroot/stdout.expected $testroot/stdout
1108 if [ "$ret" != "0" ]; then
1109 diff -u $testroot/stdout.expected $testroot/stdout
1110 test_done "$testroot" "$ret"
1114 echo "modified delta on branch" > $testroot/content.expected
1115 cat $testroot/wt/gamma/delta > $testroot/content
1116 cmp -s $testroot/content.expected $testroot/content
1118 if [ "$ret" != "0" ]; then
1119 diff -u $testroot/content.expected $testroot/content
1120 test_done "$testroot" "$ret"
1124 echo "modified alpha on master" > $testroot/content.expected
1125 cat $testroot/wt/alpha > $testroot/content
1126 cmp -s $testroot/content.expected $testroot/content
1128 if [ "$ret" != "0" ]; then
1129 diff -u $testroot/content.expected $testroot/content
1130 test_done "$testroot" "$ret"
1134 if [ -e $testroot/wt/epsilon ]; then
1135 echo "parent of removed zeta still exists on disk" >&2
1136 test_done "$testroot" "1"
1140 (cd $testroot/wt && got status > $testroot/stdout)
1142 echo -n > $testroot/stdout.expected
1143 cmp -s $testroot/stdout.expected $testroot/stdout
1145 if [ "$ret" != "0" ]; then
1146 diff -u $testroot/stdout.expected $testroot/stdout
1147 test_done "$testroot" "$ret"
1151 (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
1152 echo "commit $new_commit2 (newbranch)" > $testroot/stdout.expected
1153 echo "commit $new_commit1" >> $testroot/stdout.expected
1154 echo "commit $master_commit (master)" >> $testroot/stdout.expected
1155 cmp -s $testroot/stdout.expected $testroot/stdout
1157 if [ "$ret" != "0" ]; then
1158 diff -u $testroot/stdout.expected $testroot/stdout
1160 test_done "$testroot" "$ret"
1163 test_rebase_delete_missing_file() {
1164 local testroot=`test_init rebase_delete_missing_file`
1166 mkdir -p $testroot/repo/d/f/g
1167 echo "new file" > $testroot/repo/d/f/g/new
1168 (cd $testroot/repo && git add d/f/g/new)
1169 git_commit $testroot/repo -m "adding a subdir"
1170 local commit0=`git_show_head $testroot/repo`
1172 got br -r $testroot/repo -c master newbranch
1174 got checkout -b newbranch $testroot/repo $testroot/wt > /dev/null
1176 echo "modified delta on branch" > $testroot/wt/gamma/delta
1177 (cd $testroot/wt && got commit \
1178 -m "committing to delta on newbranch" > /dev/null)
1180 (cd $testroot/wt && got rm beta d/f/g/new > /dev/null)
1181 (cd $testroot/wt && got commit \
1182 -m "removing beta and d/f/g/new on newbranch" > /dev/null)
1184 (cd $testroot/repo && git checkout -q newbranch)
1185 local orig_commit1=`git_show_parent_commit $testroot/repo`
1186 local orig_commit2=`git_show_head $testroot/repo`
1188 (cd $testroot/wt && got update -b master > /dev/null)
1189 (cd $testroot/wt && got rm beta d/f/g/new > /dev/null)
1190 (cd $testroot/wt && got commit \
1191 -m "removing beta and d/f/g/new on master" > /dev/null)
1193 (cd $testroot/repo && git checkout -q master)
1194 local master_commit=`git_show_head $testroot/repo`
1196 (cd $testroot/wt && got update -b master > /dev/null)
1197 (cd $testroot/wt && got rebase newbranch > $testroot/stdout)
1199 (cd $testroot/repo && git checkout -q newbranch)
1200 local new_commit1=`git_show_head $testroot/repo`
1202 local short_orig_commit1=`trim_obj_id 28 $orig_commit1`
1203 local short_orig_commit2=`trim_obj_id 28 $orig_commit2`
1204 local short_new_commit1=`trim_obj_id 28 $new_commit1`
1206 echo "G gamma/delta" >> $testroot/stdout.expected
1207 echo -n "$short_orig_commit1 -> $short_new_commit1" \
1208 >> $testroot/stdout.expected
1209 echo ": committing to delta on newbranch" >> $testroot/stdout.expected
1210 echo "! beta" >> $testroot/stdout.expected
1211 echo "! d/f/g/new" >> $testroot/stdout.expected
1212 echo -n "$short_orig_commit2 -> no-op change" \
1213 >> $testroot/stdout.expected
1214 echo ": removing beta and d/f/g/new on newbranch" \
1215 >> $testroot/stdout.expected
1216 echo "Switching work tree to refs/heads/newbranch" \
1217 >> $testroot/stdout.expected
1219 cmp -s $testroot/stdout.expected $testroot/stdout
1221 if [ "$ret" != "0" ]; then
1222 diff -u $testroot/stdout.expected $testroot/stdout
1223 test_done "$testroot" "$ret"
1227 echo "modified delta on branch" > $testroot/content.expected
1228 cat $testroot/wt/gamma/delta > $testroot/content
1229 cmp -s $testroot/content.expected $testroot/content
1231 if [ "$ret" != "0" ]; then
1232 diff -u $testroot/content.expected $testroot/content
1233 test_done "$testroot" "$ret"
1237 if [ -e $testroot/wt/beta ]; then
1238 echo "removed file beta still exists on disk" >&2
1239 test_done "$testroot" "1"
1243 (cd $testroot/wt && got status > $testroot/stdout)
1245 echo -n > $testroot/stdout.expected
1246 cmp -s $testroot/stdout.expected $testroot/stdout
1248 if [ "$ret" != "0" ]; then
1249 diff -u $testroot/stdout.expected $testroot/stdout
1250 test_done "$testroot" "$ret"
1254 (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
1255 echo "commit $new_commit1 (newbranch)" > $testroot/stdout.expected
1256 echo "commit $master_commit (master)" >> $testroot/stdout.expected
1257 echo "commit $commit0" >> $testroot/stdout.expected
1258 cmp -s $testroot/stdout.expected $testroot/stdout
1260 if [ "$ret" != "0" ]; then
1261 diff -u $testroot/stdout.expected $testroot/stdout
1263 test_done "$testroot" "$ret"
1266 test_rebase_rm_add_rm_file() {
1267 local testroot=`test_init rebase_rm_add_rm_file`
1269 (cd $testroot/repo && git checkout -q -b newbranch)
1270 (cd $testroot/repo && git rm -q beta)
1271 git_commit $testroot/repo -m "removing beta from newbranch"
1272 local orig_commit1=`git_show_head $testroot/repo`
1274 echo 'restored beta' > $testroot/repo/beta
1275 (cd $testroot/repo && git add beta)
1276 git_commit $testroot/repo -m "restoring beta on newbranch"
1277 local orig_commit2=`git_show_head $testroot/repo`
1279 (cd $testroot/repo && git rm -q beta)
1280 git_commit $testroot/repo -m "removing beta from newbranch again"
1281 local orig_commit3=`git_show_head $testroot/repo`
1283 (cd $testroot/repo && git checkout -q master)
1284 echo "modified zeta on master" > $testroot/repo/epsilon/zeta
1285 git_commit $testroot/repo -m "committing to zeta on master"
1286 local master_commit=`git_show_head $testroot/repo`
1288 got checkout $testroot/repo $testroot/wt > /dev/null
1290 if [ "$ret" != "0" ]; then
1291 test_done "$testroot" "$ret"
1295 (cd $testroot/wt && got rebase newbranch > $testroot/stdout)
1297 # this would error out with 'got: file index is corrupt'
1298 (cd $testroot/wt && got status > /dev/null)
1300 if [ "$ret" != "0" ]; then
1301 echo "got status command failed unexpectedly" >&2
1302 test_done "$testroot" "$ret"
1306 (cd $testroot/repo && git checkout -q newbranch)
1307 local new_commit3=`git_show_head $testroot/repo`
1308 local new_commit2=`git_show_parent_commit $testroot/repo`
1309 local new_commit1=`git_show_parent_commit $testroot/repo $new_commit2`
1311 (cd $testroot/repo && git checkout -q newbranch)
1313 local short_orig_commit1=`trim_obj_id 28 $orig_commit1`
1314 local short_orig_commit2=`trim_obj_id 28 $orig_commit2`
1315 local short_orig_commit3=`trim_obj_id 28 $orig_commit3`
1316 local short_new_commit1=`trim_obj_id 28 $new_commit1`
1317 local short_new_commit2=`trim_obj_id 28 $new_commit2`
1318 local short_new_commit3=`trim_obj_id 28 $new_commit3`
1320 echo "D beta" > $testroot/stdout.expected
1321 echo -n "$short_orig_commit1 -> $short_new_commit1" \
1322 >> $testroot/stdout.expected
1323 echo ": removing beta from newbranch" >> $testroot/stdout.expected
1324 echo "A beta" >> $testroot/stdout.expected
1325 echo -n "$short_orig_commit2 -> $short_new_commit2" \
1326 >> $testroot/stdout.expected
1327 echo ": restoring beta on newbranch" >> $testroot/stdout.expected
1328 echo "D beta" >> $testroot/stdout.expected
1329 echo -n "$short_orig_commit3 -> $short_new_commit3" \
1330 >> $testroot/stdout.expected
1331 echo ": removing beta from newbranch again" >> $testroot/stdout.expected
1332 echo "Switching work tree to refs/heads/newbranch" \
1333 >> $testroot/stdout.expected
1335 cmp -s $testroot/stdout.expected $testroot/stdout
1337 if [ "$ret" != "0" ]; then
1338 diff -u $testroot/stdout.expected $testroot/stdout
1339 test_done "$testroot" "$ret"
1343 (cd $testroot/wt && got status > $testroot/stdout)
1345 if [ "$ret" != "0" ]; then
1346 echo "got status command failed unexpectedly" >&2
1347 test_done "$testroot" "$ret"
1351 echo -n > $testroot/stdout.expected
1352 cmp -s $testroot/stdout.expected $testroot/stdout
1354 if [ "$ret" != "0" ]; then
1355 diff -u $testroot/stdout.expected $testroot/stdout
1356 test_done "$testroot" "$ret"
1360 (cd $testroot/wt && got log -l4 | grep ^commit > $testroot/stdout)
1361 echo "commit $new_commit3 (newbranch)" > $testroot/stdout.expected
1362 echo "commit $new_commit2" >> $testroot/stdout.expected
1363 echo "commit $new_commit1" >> $testroot/stdout.expected
1364 echo "commit $master_commit (master)" >> $testroot/stdout.expected
1365 cmp -s $testroot/stdout.expected $testroot/stdout
1367 if [ "$ret" != "0" ]; then
1368 diff -u $testroot/stdout.expected $testroot/stdout
1370 test_done "$testroot" "$ret"
1374 run_test test_rebase_basic
1375 run_test test_rebase_ancestry_check
1376 run_test test_rebase_continue
1377 run_test test_rebase_abort
1378 run_test test_rebase_no_op_change
1379 run_test test_rebase_in_progress
1380 run_test test_rebase_path_prefix
1381 run_test test_rebase_preserves_logmsg
1382 run_test test_rebase_no_commits_to_rebase
1383 run_test test_rebase_forward
1384 run_test test_rebase_out_of_date
1385 run_test test_rebase_trims_empty_dir
1386 run_test test_rebase_delete_missing_file
1387 run_test test_rebase_rm_add_rm_file