Blob


1 #!/bin/sh
2 #
3 # Copyright (c) 2019, 2020 Stefan Sperling <stsp@openbsd.org>
4 #
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.
8 #
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.
17 . ./common.sh
19 test_rebase_basic() {
20 local testroot=`test_init rebase_basic`
22 (cd $testroot/repo && git checkout -q -b newbranch)
23 echo "modified delta on branch" > $testroot/repo/gamma/delta
24 git_commit $testroot/repo -m "committing to delta on newbranch"
26 echo "modified alpha on branch" > $testroot/repo/alpha
27 (cd $testroot/repo && git rm -q beta)
28 echo "new file on branch" > $testroot/repo/epsilon/new
29 (cd $testroot/repo && git add epsilon/new)
30 git_commit $testroot/repo -m "committing more changes on newbranch"
32 local orig_commit1=`git_show_parent_commit $testroot/repo`
33 local orig_commit2=`git_show_head $testroot/repo`
35 (cd $testroot/repo && git checkout -q master)
36 echo "modified zeta on master" > $testroot/repo/epsilon/zeta
37 git_commit $testroot/repo -m "committing to zeta on master"
38 local master_commit=`git_show_head $testroot/repo`
40 got checkout $testroot/repo $testroot/wt > /dev/null
41 ret="$?"
42 if [ "$ret" != "0" ]; then
43 test_done "$testroot" "$ret"
44 return 1
45 fi
47 (cd $testroot/wt && got rebase newbranch > $testroot/stdout)
49 (cd $testroot/repo && git checkout -q newbranch)
50 local new_commit1=`git_show_parent_commit $testroot/repo`
51 local new_commit2=`git_show_head $testroot/repo`
53 local short_orig_commit1=`trim_obj_id 28 $orig_commit1`
54 local short_orig_commit2=`trim_obj_id 28 $orig_commit2`
55 local short_new_commit1=`trim_obj_id 28 $new_commit1`
56 local short_new_commit2=`trim_obj_id 28 $new_commit2`
58 echo "G gamma/delta" >> $testroot/stdout.expected
59 echo -n "$short_orig_commit1 -> $short_new_commit1" \
60 >> $testroot/stdout.expected
61 echo ": committing to delta on newbranch" >> $testroot/stdout.expected
62 echo "G alpha" >> $testroot/stdout.expected
63 echo "D beta" >> $testroot/stdout.expected
64 echo "A epsilon/new" >> $testroot/stdout.expected
65 echo -n "$short_orig_commit2 -> $short_new_commit2" \
66 >> $testroot/stdout.expected
67 echo ": committing more changes on newbranch" \
68 >> $testroot/stdout.expected
69 echo "Switching work tree to refs/heads/newbranch" \
70 >> $testroot/stdout.expected
72 cmp -s $testroot/stdout.expected $testroot/stdout
73 ret="$?"
74 if [ "$ret" != "0" ]; then
75 diff -u $testroot/stdout.expected $testroot/stdout
76 test_done "$testroot" "$ret"
77 return 1
78 fi
80 echo "modified delta on branch" > $testroot/content.expected
81 cat $testroot/wt/gamma/delta > $testroot/content
82 cmp -s $testroot/content.expected $testroot/content
83 ret="$?"
84 if [ "$ret" != "0" ]; then
85 diff -u $testroot/content.expected $testroot/content
86 test_done "$testroot" "$ret"
87 return 1
88 fi
90 echo "modified alpha on branch" > $testroot/content.expected
91 cat $testroot/wt/alpha > $testroot/content
92 cmp -s $testroot/content.expected $testroot/content
93 ret="$?"
94 if [ "$ret" != "0" ]; then
95 diff -u $testroot/content.expected $testroot/content
96 test_done "$testroot" "$ret"
97 return 1
98 fi
100 if [ -e $testroot/wt/beta ]; then
101 echo "removed file beta still exists on disk" >&2
102 test_done "$testroot" "1"
103 return 1
104 fi
106 echo "new file on branch" > $testroot/content.expected
107 cat $testroot/wt/epsilon/new > $testroot/content
108 cmp -s $testroot/content.expected $testroot/content
109 ret="$?"
110 if [ "$ret" != "0" ]; then
111 diff -u $testroot/content.expected $testroot/content
112 test_done "$testroot" "$ret"
113 return 1
114 fi
116 (cd $testroot/wt && got status > $testroot/stdout)
118 echo -n > $testroot/stdout.expected
119 cmp -s $testroot/stdout.expected $testroot/stdout
120 ret="$?"
121 if [ "$ret" != "0" ]; then
122 diff -u $testroot/stdout.expected $testroot/stdout
123 test_done "$testroot" "$ret"
124 return 1
125 fi
127 (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
128 echo "commit $new_commit2 (newbranch)" > $testroot/stdout.expected
129 echo "commit $new_commit1" >> $testroot/stdout.expected
130 echo "commit $master_commit (master)" >> $testroot/stdout.expected
131 cmp -s $testroot/stdout.expected $testroot/stdout
132 ret="$?"
133 if [ "$ret" != "0" ]; then
134 diff -u $testroot/stdout.expected $testroot/stdout
135 test_done "$testroot" "$ret"
136 return 1
137 fi
139 (cd $testroot/wt && got update > $testroot/stdout)
141 echo 'Already up-to-date' > $testroot/stdout.expected
142 cmp -s $testroot/stdout.expected $testroot/stdout
143 ret="$?"
144 if [ "$ret" != "0" ]; then
145 diff -u $testroot/stdout.expected $testroot/stdout
146 fi
147 test_done "$testroot" "$ret"
150 test_rebase_ancestry_check() {
151 local testroot=`test_init rebase_ancestry_check`
153 got checkout $testroot/repo $testroot/wt > /dev/null
154 ret="$?"
155 if [ "$ret" != "0" ]; then
156 test_done "$testroot" "$ret"
157 return 1
158 fi
160 (cd $testroot/repo && git checkout -q -b newbranch)
161 echo "modified delta on branch" > $testroot/repo/gamma/delta
162 git_commit $testroot/repo -m "committing to delta on newbranch"
164 (cd $testroot/wt && got rebase newbranch > $testroot/stdout \
165 2> $testroot/stderr)
167 echo -n > $testroot/stdout.expected
168 cmp -s $testroot/stdout.expected $testroot/stdout
169 ret="$?"
170 if [ "$ret" != "0" ]; then
171 diff -u $testroot/stdout.expected $testroot/stdout
172 test_done "$testroot" "$ret"
173 return 1
174 fi
176 echo "got: refs/heads/newbranch is already based on refs/heads/master" \
177 > $testroot/stderr.expected
178 cmp -s $testroot/stderr.expected $testroot/stderr
179 ret="$?"
180 if [ "$ret" != "0" ]; then
181 diff -u $testroot/stderr.expected $testroot/stderr
182 fi
183 test_done "$testroot" "$ret"
186 test_rebase_continue() {
187 local testroot=`test_init rebase_continue`
188 local init_commit=`git_show_head $testroot/repo`
190 (cd $testroot/repo && git checkout -q -b newbranch)
191 echo "modified alpha on branch" > $testroot/repo/alpha
192 git_commit $testroot/repo -m "committing to alpha on newbranch"
193 local orig_commit1=`git_show_head $testroot/repo`
194 local short_orig_commit1=`trim_obj_id 28 $orig_commit1`
196 (cd $testroot/repo && git checkout -q master)
197 echo "modified alpha on master" > $testroot/repo/alpha
198 git_commit $testroot/repo -m "committing to alpha on master"
199 local master_commit=`git_show_head $testroot/repo`
201 got checkout $testroot/repo $testroot/wt > /dev/null
202 ret="$?"
203 if [ "$ret" != "0" ]; then
204 test_done "$testroot" "$ret"
205 return 1
206 fi
208 (cd $testroot/wt && got rebase newbranch > $testroot/stdout \
209 2> $testroot/stderr)
211 echo "C alpha" > $testroot/stdout.expected
212 echo "Files with new merge conflicts: 1" >> $testroot/stdout.expected
213 echo -n "$short_orig_commit1 -> merge conflict" \
214 >> $testroot/stdout.expected
215 echo ": committing to alpha on newbranch" >> $testroot/stdout.expected
216 cmp -s $testroot/stdout.expected $testroot/stdout
217 ret="$?"
218 if [ "$ret" != "0" ]; then
219 diff -u $testroot/stdout.expected $testroot/stdout
220 test_done "$testroot" "$ret"
221 return 1
222 fi
224 echo "got: conflicts must be resolved before rebasing can continue" \
225 > $testroot/stderr.expected
226 cmp -s $testroot/stderr.expected $testroot/stderr
227 ret="$?"
228 if [ "$ret" != "0" ]; then
229 diff -u $testroot/stderr.expected $testroot/stderr
230 test_done "$testroot" "$ret"
231 return 1
232 fi
234 echo "<<<<<<< merged change: commit $orig_commit1" \
235 > $testroot/content.expected
236 echo "modified alpha on branch" >> $testroot/content.expected
237 echo "||||||| 3-way merge base: commit $init_commit" \
238 >> $testroot/content.expected
239 echo "alpha" >> $testroot/content.expected
240 echo "=======" >> $testroot/content.expected
241 echo "modified alpha on master" >> $testroot/content.expected
242 echo '>>>>>>>' >> $testroot/content.expected
243 cat $testroot/wt/alpha > $testroot/content
244 cmp -s $testroot/content.expected $testroot/content
245 ret="$?"
246 if [ "$ret" != "0" ]; then
247 diff -u $testroot/content.expected $testroot/content
248 test_done "$testroot" "$ret"
249 return 1
250 fi
252 (cd $testroot/wt && got status > $testroot/stdout)
254 echo "C alpha" > $testroot/stdout.expected
255 cmp -s $testroot/stdout.expected $testroot/stdout
256 ret="$?"
257 if [ "$ret" != "0" ]; then
258 diff -u $testroot/stdout.expected $testroot/stdout
259 test_done "$testroot" "$ret"
260 return 1
261 fi
263 # resolve the conflict
264 echo "modified alpha on branch and master" > $testroot/wt/alpha
266 # test interaction of 'got stage' and rebase -c
267 (cd $testroot/wt && got stage alpha > /dev/null)
268 (cd $testroot/wt && got rebase -c > $testroot/stdout \
269 2> $testroot/stderr)
270 ret="$?"
271 if [ "$ret" = "0" ]; then
272 echo "rebase succeeded unexpectedly" >&2
273 test_done "$testroot" "1"
274 return 1
275 fi
276 echo -n "got: work tree contains files with staged changes; " \
277 > $testroot/stderr.expected
278 echo "these changes must be committed or unstaged first" \
279 >> $testroot/stderr.expected
280 cmp -s $testroot/stderr.expected $testroot/stderr
281 ret="$?"
282 if [ "$ret" != "0" ]; then
283 diff -u $testroot/stderr.expected $testroot/stderr
284 test_done "$testroot" "$ret"
285 return 1
286 fi
288 (cd $testroot/wt && got unstage alpha > /dev/null)
289 (cd $testroot/wt && got rebase -c > $testroot/stdout)
291 (cd $testroot/repo && git checkout -q newbranch)
292 local new_commit1=`git_show_head $testroot/repo`
293 local short_new_commit1=`trim_obj_id 28 $new_commit1`
295 echo -n "$short_orig_commit1 -> $short_new_commit1" \
296 > $testroot/stdout.expected
297 echo ": committing to alpha on newbranch" >> $testroot/stdout.expected
298 echo "Switching work tree to refs/heads/newbranch" \
299 >> $testroot/stdout.expected
301 cmp -s $testroot/stdout.expected $testroot/stdout
302 ret="$?"
303 if [ "$ret" != "0" ]; then
304 diff -u $testroot/stdout.expected $testroot/stdout
305 test_done "$testroot" "$ret"
306 return 1
307 fi
310 (cd $testroot/wt && got log -l2 | grep ^commit > $testroot/stdout)
311 echo "commit $new_commit1 (newbranch)" > $testroot/stdout.expected
312 echo "commit $master_commit (master)" >> $testroot/stdout.expected
313 cmp -s $testroot/stdout.expected $testroot/stdout
314 ret="$?"
315 if [ "$ret" != "0" ]; then
316 diff -u $testroot/stdout.expected $testroot/stdout
317 fi
318 test_done "$testroot" "$ret"
321 test_rebase_abort() {
322 local testroot=`test_init rebase_abort`
324 local init_commit=`git_show_head $testroot/repo`
326 (cd $testroot/repo && git checkout -q -b newbranch)
327 echo "modified alpha on branch" > $testroot/repo/alpha
328 git_commit $testroot/repo -m "committing to alpha on newbranch"
329 local orig_commit1=`git_show_head $testroot/repo`
330 local short_orig_commit1=`trim_obj_id 28 $orig_commit1`
332 (cd $testroot/repo && git checkout -q master)
333 echo "modified alpha on master" > $testroot/repo/alpha
334 git_commit $testroot/repo -m "committing to alpha on master"
335 local master_commit=`git_show_head $testroot/repo`
337 got checkout $testroot/repo $testroot/wt > /dev/null
338 ret="$?"
339 if [ "$ret" != "0" ]; then
340 test_done "$testroot" "$ret"
341 return 1
342 fi
344 (cd $testroot/wt && got rebase newbranch > $testroot/stdout \
345 2> $testroot/stderr)
347 echo "C alpha" > $testroot/stdout.expected
348 echo "Files with new merge conflicts: 1" >> $testroot/stdout.expected
349 echo -n "$short_orig_commit1 -> merge conflict" \
350 >> $testroot/stdout.expected
351 echo ": committing to alpha on newbranch" >> $testroot/stdout.expected
352 cmp -s $testroot/stdout.expected $testroot/stdout
353 ret="$?"
354 if [ "$ret" != "0" ]; then
355 diff -u $testroot/stdout.expected $testroot/stdout
356 test_done "$testroot" "$ret"
357 return 1
358 fi
360 echo "got: conflicts must be resolved before rebasing can continue" \
361 > $testroot/stderr.expected
362 cmp -s $testroot/stderr.expected $testroot/stderr
363 ret="$?"
364 if [ "$ret" != "0" ]; then
365 diff -u $testroot/stderr.expected $testroot/stderr
366 test_done "$testroot" "$ret"
367 return 1
368 fi
370 echo "<<<<<<< merged change: commit $orig_commit1" \
371 > $testroot/content.expected
372 echo "modified alpha on branch" >> $testroot/content.expected
373 echo "||||||| 3-way merge base: commit $init_commit" \
374 >> $testroot/content.expected
375 echo "alpha" >> $testroot/content.expected
376 echo "=======" >> $testroot/content.expected
377 echo "modified alpha on master" >> $testroot/content.expected
378 echo '>>>>>>>' >> $testroot/content.expected
379 cat $testroot/wt/alpha > $testroot/content
380 cmp -s $testroot/content.expected $testroot/content
381 ret="$?"
382 if [ "$ret" != "0" ]; then
383 diff -u $testroot/content.expected $testroot/content
384 test_done "$testroot" "$ret"
385 return 1
386 fi
388 (cd $testroot/wt && got status > $testroot/stdout)
390 echo "C alpha" > $testroot/stdout.expected
391 cmp -s $testroot/stdout.expected $testroot/stdout
392 ret="$?"
393 if [ "$ret" != "0" ]; then
394 diff -u $testroot/stdout.expected $testroot/stdout
395 test_done "$testroot" "$ret"
396 return 1
397 fi
399 (cd $testroot/wt && got rebase -a > $testroot/stdout)
401 (cd $testroot/repo && git checkout -q newbranch)
403 echo "Switching work tree to refs/heads/master" \
404 > $testroot/stdout.expected
405 echo 'R alpha' >> $testroot/stdout.expected
406 echo "Rebase of refs/heads/newbranch aborted" \
407 >> $testroot/stdout.expected
409 cmp -s $testroot/stdout.expected $testroot/stdout
410 ret="$?"
411 if [ "$ret" != "0" ]; then
412 diff -u $testroot/stdout.expected $testroot/stdout
413 test_done "$testroot" "$ret"
414 return 1
415 fi
417 echo "modified alpha on master" > $testroot/content.expected
418 cat $testroot/wt/alpha > $testroot/content
419 cmp -s $testroot/content.expected $testroot/content
420 ret="$?"
421 if [ "$ret" != "0" ]; then
422 diff -u $testroot/content.expected $testroot/content
423 test_done "$testroot" "$ret"
424 return 1
425 fi
427 (cd $testroot/wt && got log -l3 -c newbranch \
428 | grep ^commit > $testroot/stdout)
429 echo "commit $orig_commit1 (newbranch)" > $testroot/stdout.expected
430 echo "commit $init_commit" >> $testroot/stdout.expected
431 cmp -s $testroot/stdout.expected $testroot/stdout
432 ret="$?"
433 if [ "$ret" != "0" ]; then
434 diff -u $testroot/stdout.expected $testroot/stdout
435 fi
436 test_done "$testroot" "$ret"
439 test_rebase_no_op_change() {
440 local testroot=`test_init rebase_no_op_change`
441 local init_commit=`git_show_head $testroot/repo`
443 (cd $testroot/repo && git checkout -q -b newbranch)
444 echo "modified alpha on branch" > $testroot/repo/alpha
445 git_commit $testroot/repo -m "committing to alpha on newbranch"
446 local orig_commit1=`git_show_head $testroot/repo`
447 local short_orig_commit1=`trim_obj_id 28 $orig_commit1`
449 (cd $testroot/repo && git checkout -q master)
450 echo "modified alpha on master" > $testroot/repo/alpha
451 git_commit $testroot/repo -m "committing to alpha on master"
452 local master_commit=`git_show_head $testroot/repo`
454 got checkout $testroot/repo $testroot/wt > /dev/null
455 ret="$?"
456 if [ "$ret" != "0" ]; then
457 test_done "$testroot" "$ret"
458 return 1
459 fi
461 (cd $testroot/wt && got rebase newbranch > $testroot/stdout \
462 2> $testroot/stderr)
464 echo "C alpha" > $testroot/stdout.expected
465 echo "Files with new merge conflicts: 1" >> $testroot/stdout.expected
466 echo -n "$short_orig_commit1 -> merge conflict" \
467 >> $testroot/stdout.expected
468 echo ": committing to alpha on newbranch" >> $testroot/stdout.expected
469 cmp -s $testroot/stdout.expected $testroot/stdout
470 ret="$?"
471 if [ "$ret" != "0" ]; then
472 diff -u $testroot/stdout.expected $testroot/stdout
473 test_done "$testroot" "$ret"
474 return 1
475 fi
477 echo "got: conflicts must be resolved before rebasing can continue" \
478 > $testroot/stderr.expected
479 cmp -s $testroot/stderr.expected $testroot/stderr
480 ret="$?"
481 if [ "$ret" != "0" ]; then
482 diff -u $testroot/stderr.expected $testroot/stderr
483 test_done "$testroot" "$ret"
484 return 1
485 fi
487 echo "<<<<<<< merged change: commit $orig_commit1" \
488 > $testroot/content.expected
489 echo "modified alpha on branch" >> $testroot/content.expected
490 echo "||||||| 3-way merge base: commit $init_commit" \
491 >> $testroot/content.expected
492 echo "alpha" >> $testroot/content.expected
493 echo "=======" >> $testroot/content.expected
494 echo "modified alpha on master" >> $testroot/content.expected
495 echo '>>>>>>>' >> $testroot/content.expected
496 cat $testroot/wt/alpha > $testroot/content
497 cmp -s $testroot/content.expected $testroot/content
498 ret="$?"
499 if [ "$ret" != "0" ]; then
500 diff -u $testroot/content.expected $testroot/content
501 test_done "$testroot" "$ret"
502 return 1
503 fi
505 (cd $testroot/wt && got status > $testroot/stdout)
507 echo "C alpha" > $testroot/stdout.expected
508 cmp -s $testroot/stdout.expected $testroot/stdout
509 ret="$?"
510 if [ "$ret" != "0" ]; then
511 diff -u $testroot/stdout.expected $testroot/stdout
512 test_done "$testroot" "$ret"
513 return 1
514 fi
516 # resolve the conflict
517 echo "modified alpha on master" > $testroot/wt/alpha
519 (cd $testroot/wt && got rebase -c > $testroot/stdout)
521 (cd $testroot/repo && git checkout -q newbranch)
522 local new_commit1=`git_show_head $testroot/repo`
524 echo -n "$short_orig_commit1 -> no-op change" \
525 > $testroot/stdout.expected
526 echo ": committing to alpha on newbranch" >> $testroot/stdout.expected
527 echo "Switching work tree to refs/heads/newbranch" \
528 >> $testroot/stdout.expected
530 cmp -s $testroot/stdout.expected $testroot/stdout
531 ret="$?"
532 if [ "$ret" != "0" ]; then
533 diff -u $testroot/stdout.expected $testroot/stdout
534 test_done "$testroot" "$ret"
535 return 1
536 fi
539 (cd $testroot/wt && got log -l2 | grep ^commit > $testroot/stdout)
540 echo "commit $master_commit (master, newbranch)" \
541 > $testroot/stdout.expected
542 echo "commit $init_commit" >> $testroot/stdout.expected
543 cmp -s $testroot/stdout.expected $testroot/stdout
544 ret="$?"
545 if [ "$ret" != "0" ]; then
546 diff -u $testroot/stdout.expected $testroot/stdout
547 fi
548 test_done "$testroot" "$ret"
551 test_rebase_in_progress() {
552 local testroot=`test_init rebase_in_progress`
553 local init_commit=`git_show_head $testroot/repo`
555 (cd $testroot/repo && git checkout -q -b newbranch)
556 echo "modified alpha on branch" > $testroot/repo/alpha
557 git_commit $testroot/repo -m "committing to alpha on newbranch"
558 local orig_commit1=`git_show_head $testroot/repo`
559 local short_orig_commit1=`trim_obj_id 28 $orig_commit1`
561 (cd $testroot/repo && git checkout -q master)
562 echo "modified alpha on master" > $testroot/repo/alpha
563 git_commit $testroot/repo -m "committing to alpha on master"
564 local master_commit=`git_show_head $testroot/repo`
566 got checkout $testroot/repo $testroot/wt > /dev/null
567 ret="$?"
568 if [ "$ret" != "0" ]; then
569 test_done "$testroot" "$ret"
570 return 1
571 fi
573 (cd $testroot/wt && got rebase newbranch > $testroot/stdout \
574 2> $testroot/stderr)
576 echo "C alpha" > $testroot/stdout.expected
577 echo "Files with new merge conflicts: 1" >> $testroot/stdout.expected
578 echo -n "$short_orig_commit1 -> merge conflict" \
579 >> $testroot/stdout.expected
580 echo ": committing to alpha on newbranch" >> $testroot/stdout.expected
581 cmp -s $testroot/stdout.expected $testroot/stdout
582 ret="$?"
583 if [ "$ret" != "0" ]; then
584 diff -u $testroot/stdout.expected $testroot/stdout
585 test_done "$testroot" "$ret"
586 return 1
587 fi
589 echo "got: conflicts must be resolved before rebasing can continue" \
590 > $testroot/stderr.expected
591 cmp -s $testroot/stderr.expected $testroot/stderr
592 ret="$?"
593 if [ "$ret" != "0" ]; then
594 diff -u $testroot/stderr.expected $testroot/stderr
595 test_done "$testroot" "$ret"
596 return 1
597 fi
599 echo "<<<<<<< merged change: commit $orig_commit1" \
600 > $testroot/content.expected
601 echo "modified alpha on branch" >> $testroot/content.expected
602 echo "||||||| 3-way merge base: commit $init_commit" \
603 >> $testroot/content.expected
604 echo "alpha" >> $testroot/content.expected
605 echo "=======" >> $testroot/content.expected
606 echo "modified alpha on master" >> $testroot/content.expected
607 echo '>>>>>>>' >> $testroot/content.expected
608 cat $testroot/wt/alpha > $testroot/content
609 cmp -s $testroot/content.expected $testroot/content
610 ret="$?"
611 if [ "$ret" != "0" ]; then
612 diff -u $testroot/content.expected $testroot/content
613 test_done "$testroot" "$ret"
614 return 1
615 fi
617 (cd $testroot/wt && got status > $testroot/stdout)
619 echo "C alpha" > $testroot/stdout.expected
620 cmp -s $testroot/stdout.expected $testroot/stdout
621 ret="$?"
622 if [ "$ret" != "0" ]; then
623 diff -u $testroot/stdout.expected $testroot/stdout
624 test_done "$testroot" "$ret"
625 return 1
626 fi
628 for cmd in update commit; do
629 (cd $testroot/wt && got $cmd > $testroot/stdout \
630 2> $testroot/stderr)
632 echo -n > $testroot/stdout.expected
633 cmp -s $testroot/stdout.expected $testroot/stdout
634 ret="$?"
635 if [ "$ret" != "0" ]; then
636 diff -u $testroot/stdout.expected $testroot/stdout
637 test_done "$testroot" "$ret"
638 return 1
639 fi
641 echo -n "got: a rebase operation is in progress in this " \
642 > $testroot/stderr.expected
643 echo "work tree and must be continued or aborted first" \
644 >> $testroot/stderr.expected
645 cmp -s $testroot/stderr.expected $testroot/stderr
646 ret="$?"
647 if [ "$ret" != "0" ]; then
648 diff -u $testroot/stderr.expected $testroot/stderr
649 test_done "$testroot" "$ret"
650 return 1
651 fi
652 done
654 test_done "$testroot" "$ret"
657 test_rebase_path_prefix() {
658 local testroot=`test_init rebase_path_prefix`
660 (cd $testroot/repo && git checkout -q -b newbranch)
661 echo "modified delta on branch" > $testroot/repo/gamma/delta
662 git_commit $testroot/repo -m "committing to delta on newbranch"
664 local orig_commit1=`git_show_parent_commit $testroot/repo`
665 local orig_commit2=`git_show_head $testroot/repo`
667 (cd $testroot/repo && git checkout -q master)
668 echo "modified zeta on master" > $testroot/repo/epsilon/zeta
669 git_commit $testroot/repo -m "committing to zeta on master"
670 local master_commit=`git_show_head $testroot/repo`
672 got checkout -p epsilon $testroot/repo $testroot/wt > /dev/null
673 ret="$?"
674 if [ "$ret" != "0" ]; then
675 test_done "$testroot" "$ret"
676 return 1
677 fi
679 (cd $testroot/wt && got rebase newbranch \
680 > $testroot/stdout 2> $testroot/stderr)
682 echo -n > $testroot/stdout.expected
683 cmp -s $testroot/stdout.expected $testroot/stdout
684 ret="$?"
685 if [ "$ret" != "0" ]; then
686 diff -u $testroot/stdout.expected $testroot/stdout
687 test_done "$testroot" "$ret"
688 return 1
689 fi
691 echo -n "got: cannot rebase branch which contains changes outside " \
692 > $testroot/stderr.expected
693 echo "of this work tree's path prefix" >> $testroot/stderr.expected
694 cmp -s $testroot/stderr.expected $testroot/stderr
695 ret="$?"
696 if [ "$ret" != "0" ]; then
697 diff -u $testroot/stderr.expected $testroot/stderr
698 fi
699 test_done "$testroot" "$ret"
702 test_rebase_preserves_logmsg() {
703 local testroot=`test_init rebase_preserves_logmsg`
705 (cd $testroot/repo && git checkout -q -b newbranch)
706 echo "modified delta on branch" > $testroot/repo/gamma/delta
707 git_commit $testroot/repo -m "modified delta on newbranch"
709 echo "modified alpha on branch" > $testroot/repo/alpha
710 git_commit $testroot/repo -m "modified alpha on newbranch"
712 (cd $testroot/repo && got log -c newbranch -l2 | grep -v ^date: \
713 > $testroot/log.expected)
715 local orig_commit1=`git_show_parent_commit $testroot/repo`
716 local orig_commit2=`git_show_head $testroot/repo`
718 (cd $testroot/repo && git checkout -q master)
719 echo "modified zeta on master" > $testroot/repo/epsilon/zeta
720 git_commit $testroot/repo -m "committing to zeta on master"
721 local master_commit=`git_show_head $testroot/repo`
723 got checkout $testroot/repo $testroot/wt > /dev/null
724 ret="$?"
725 if [ "$ret" != "0" ]; then
726 test_done "$testroot" "$ret"
727 return 1
728 fi
730 (cd $testroot/wt && got rebase newbranch > /dev/null \
731 2> $testroot/stderr)
733 (cd $testroot/repo && git checkout -q newbranch)
734 local new_commit1=`git_show_parent_commit $testroot/repo`
735 local new_commit2=`git_show_head $testroot/repo`
737 echo -n > $testroot/stderr.expected
738 cmp -s $testroot/stderr.expected $testroot/stderr
739 ret="$?"
740 if [ "$ret" != "0" ]; then
741 diff -u $testroot/stderr.expected $testroot/stderr
742 test_done "$testroot" "$ret"
743 return 1
744 fi
746 (cd $testroot/wt && got log -c newbranch -l2 | grep -v ^date: \
747 > $testroot/log)
748 sed -i -e "s/$orig_commit1/$new_commit1/" $testroot/log.expected
749 sed -i -e "s/$orig_commit2/$new_commit2/" $testroot/log.expected
750 cmp -s $testroot/log.expected $testroot/log
751 ret="$?"
752 if [ "$ret" != "0" ]; then
753 diff -u $testroot/log.expected $testroot/log
754 fi
756 test_done "$testroot" "$ret"
759 test_rebase_no_commits_to_rebase() {
760 local testroot=`test_init rebase_no_commits_to_rebase`
762 got checkout $testroot/repo $testroot/wt > /dev/null
763 ret="$?"
764 if [ "$ret" != "0" ]; then
765 test_done "$testroot" "$ret"
766 return 1
767 fi
769 (cd $testroot/wt && got branch -n newbranch)
771 echo "modified alpha on master" > $testroot/wt/alpha
772 (cd $testroot/wt && got commit -m 'test rebase_no_commits_to_rebase' \
773 > /dev/null)
774 (cd $testroot/wt && got update > /dev/null)
776 (cd $testroot/wt && got rebase newbranch > $testroot/stdout \
777 2> $testroot/stderr)
779 echo "got: no commits to rebase" > $testroot/stderr.expected
780 cmp -s $testroot/stderr.expected $testroot/stderr
781 ret="$?"
782 if [ "$ret" != "0" ]; then
783 diff -u $testroot/stderr.expected $testroot/stderr
784 test_done "$testroot" "$ret"
785 return 1
786 fi
788 echo "Rebase of refs/heads/newbranch aborted" \
789 > $testroot/stdout.expected
790 cmp -s $testroot/stdout.expected $testroot/stdout
791 ret="$?"
792 if [ "$ret" != "0" ]; then
793 diff -u $testroot/stdout.expected $testroot/stdout
794 test_done "$testroot" "$ret"
795 return 1
796 fi
798 (cd $testroot/wt && got update > $testroot/stdout)
799 echo "Already up-to-date" > $testroot/stdout.expected
800 cmp -s $testroot/stdout.expected $testroot/stdout
801 ret="$?"
802 if [ "$ret" != "0" ]; then
803 diff -u $testroot/stdout.expected $testroot/stdout
804 fi
805 test_done "$testroot" "$ret"
808 test_rebase_forward() {
809 local testroot=`test_init rebase_forward`
810 local commit0=`git_show_head $testroot/repo`
812 got checkout $testroot/repo $testroot/wt > /dev/null
813 ret="$?"
814 if [ "$ret" != "0" ]; then
815 test_done "$testroot" "$ret"
816 return 1
817 fi
819 echo "change alpha 1" > $testroot/wt/alpha
820 (cd $testroot/wt && got commit -m 'test rebase_forward' \
821 > /dev/null)
822 local commit1=`git_show_head $testroot/repo`
824 echo "change alpha 2" > $testroot/wt/alpha
825 (cd $testroot/wt && got commit -m 'test rebase_forward' \
826 > /dev/null)
827 local commit2=`git_show_head $testroot/repo`
829 # Simulate a situation where fast-forward is required.
830 # We want to fast-forward master to origin/master:
831 # commit 3907e11dceaae2ca7f8db79c2af31794673945ad (origin/master)
832 # commit ffcffcd102cf1af6572fbdbb4cf07a0f1fd2d840 (master)
833 # commit 87a6a8a2263a15b61c016ff1720b24741d455eb5
834 (cd $testroot/repo && got ref -d master)
835 (cd $testroot/repo && got ref -c $commit1 refs/heads/master)
836 (cd $testroot/repo && got ref -c $commit2 refs/remotes/origin/master)
838 (cd $testroot/wt && got up -b origin/master > /dev/null)
840 (cd $testroot/wt && got rebase master \
841 > $testroot/stdout 2> $testroot/stderr)
843 echo "Forwarding refs/heads/master to commit $commit2" \
844 > $testroot/stdout.expected
845 echo "Switching work tree to refs/heads/master" \
846 >> $testroot/stdout.expected
847 cmp -s $testroot/stdout.expected $testroot/stdout
848 ret="$?"
849 if [ "$ret" != "0" ]; then
850 diff -u $testroot/stdout.expected $testroot/stdout
851 test_done "$testroot" "$ret"
852 return 1
853 fi
855 # Ensure that rebase operation was completed correctly
856 (cd $testroot/wt && got rebase -a \
857 > $testroot/stdout 2> $testroot/stderr)
858 echo -n "" > $testroot/stdout.expected
859 cmp -s $testroot/stdout.expected $testroot/stdout
860 ret="$?"
861 if [ "$ret" != "0" ]; then
862 diff -u $testroot/stdout.expected $testroot/stdout
863 test_done "$testroot" "$ret"
864 return 1
865 fi
866 echo "got: rebase operation not in progress" > $testroot/stderr.expected
867 cmp -s $testroot/stderr.expected $testroot/stderr
868 ret="$?"
869 if [ "$ret" != "0" ]; then
870 diff -u $testroot/stderr.expected $testroot/stderr
871 test_done "$testroot" "$ret"
872 return 1
873 fi
875 (cd $testroot/wt && got branch -n > $testroot/stdout)
876 echo "master" > $testroot/stdout.expected
877 cmp -s $testroot/stdout.expected $testroot/stdout
878 ret="$?"
879 if [ "$ret" != "0" ]; then
880 diff -u $testroot/stdout.expected $testroot/stdout
881 test_done "$testroot" "$ret"
882 return 1
883 fi
885 (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
886 echo "commit $commit2 (master, origin/master)" > $testroot/stdout.expected
887 echo "commit $commit1" >> $testroot/stdout.expected
888 echo "commit $commit0" >> $testroot/stdout.expected
889 cmp -s $testroot/stdout.expected $testroot/stdout
890 ret="$?"
891 if [ "$ret" != "0" ]; then
892 diff -u $testroot/stdout.expected $testroot/stdout
893 fi
894 test_done "$testroot" "$ret"
897 test_rebase_out_of_date() {
898 local testroot=`test_init rebase_out_of_date`
899 local initial_commit=`git_show_head $testroot/repo`
901 (cd $testroot/repo && git checkout -q -b newbranch)
902 echo "modified delta on branch" > $testroot/repo/gamma/delta
903 git_commit $testroot/repo -m "committing to delta on newbranch"
905 echo "modified alpha on branch" > $testroot/repo/alpha
906 (cd $testroot/repo && git rm -q beta)
907 echo "new file on branch" > $testroot/repo/epsilon/new
908 (cd $testroot/repo && git add epsilon/new)
909 git_commit $testroot/repo -m "committing more changes on newbranch"
911 local orig_commit1=`git_show_parent_commit $testroot/repo`
912 local orig_commit2=`git_show_head $testroot/repo`
914 (cd $testroot/repo && git checkout -q master)
915 echo "modified zeta on master" > $testroot/repo/epsilon/zeta
916 git_commit $testroot/repo -m "committing to zeta on master"
917 local master_commit1=`git_show_head $testroot/repo`
919 (cd $testroot/repo && git checkout -q master)
920 echo "modified beta on master" > $testroot/repo/beta
921 git_commit $testroot/repo -m "committing to beta on master"
922 local master_commit2=`git_show_head $testroot/repo`
924 got checkout -c $master_commit1 $testroot/repo $testroot/wt \
925 > /dev/null
926 ret="$?"
927 if [ "$ret" != "0" ]; then
928 test_done "$testroot" "$ret"
929 return 1
930 fi
932 (cd $testroot/wt && got rebase newbranch > $testroot/stdout \
933 2> $testroot/stderr)
935 echo -n > $testroot/stdout.expected
936 cmp -s $testroot/stdout.expected $testroot/stdout
937 ret="$?"
938 if [ "$ret" != "0" ]; then
939 diff -u $testroot/stdout.expected $testroot/stdout
940 test_done "$testroot" "$ret"
941 return 1
942 fi
944 echo -n "got: work tree must be updated before it can be " \
945 > $testroot/stderr.expected
946 echo "used to rebase a branch" >> $testroot/stderr.expected
947 cmp -s $testroot/stderr.expected $testroot/stderr
948 ret="$?"
949 if [ "$ret" != "0" ]; then
950 diff -u $testroot/stderr.expected $testroot/stderr
951 test_done "$testroot" "$ret"
952 return 1
953 fi
955 (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
956 echo "commit $master_commit2 (master)" > $testroot/stdout.expected
957 echo "commit $master_commit1" >> $testroot/stdout.expected
958 echo "commit $initial_commit" >> $testroot/stdout.expected
959 cmp -s $testroot/stdout.expected $testroot/stdout
960 ret="$?"
961 if [ "$ret" != "0" ]; then
962 diff -u $testroot/stdout.expected $testroot/stdout
963 fi
964 test_done "$testroot" "$ret"
967 test_rebase_trims_empty_dir() {
968 local testroot=`test_init rebase_trims_empty_dir`
970 (cd $testroot/repo && git checkout -q -b newbranch)
971 echo "modified delta on branch" > $testroot/repo/gamma/delta
972 git_commit $testroot/repo -m "committing to delta on newbranch"
974 (cd $testroot/repo && git rm -q epsilon/zeta)
975 git_commit $testroot/repo -m "removing zeta on newbranch"
977 local orig_commit1=`git_show_parent_commit $testroot/repo`
978 local orig_commit2=`git_show_head $testroot/repo`
980 (cd $testroot/repo && git checkout -q master)
981 echo "modified alpha on master" > $testroot/repo/alpha
982 git_commit $testroot/repo -m "committing to alpha on master"
983 local master_commit=`git_show_head $testroot/repo`
985 got checkout $testroot/repo $testroot/wt > /dev/null
986 ret="$?"
987 if [ "$ret" != "0" ]; then
988 test_done "$testroot" "$ret"
989 return 1
990 fi
992 (cd $testroot/wt && got rebase newbranch > $testroot/stdout)
994 (cd $testroot/repo && git checkout -q newbranch)
995 local new_commit1=`git_show_parent_commit $testroot/repo`
996 local new_commit2=`git_show_head $testroot/repo`
998 local short_orig_commit1=`trim_obj_id 28 $orig_commit1`
999 local short_orig_commit2=`trim_obj_id 28 $orig_commit2`
1000 local short_new_commit1=`trim_obj_id 28 $new_commit1`
1001 local short_new_commit2=`trim_obj_id 28 $new_commit2`
1003 echo "G gamma/delta" >> $testroot/stdout.expected
1004 echo -n "$short_orig_commit1 -> $short_new_commit1" \
1005 >> $testroot/stdout.expected
1006 echo ": committing to delta on newbranch" >> $testroot/stdout.expected
1007 echo "D epsilon/zeta" >> $testroot/stdout.expected
1008 echo -n "$short_orig_commit2 -> $short_new_commit2" \
1009 >> $testroot/stdout.expected
1010 echo ": removing zeta on newbranch" \
1011 >> $testroot/stdout.expected
1012 echo "Switching work tree to refs/heads/newbranch" \
1013 >> $testroot/stdout.expected
1015 cmp -s $testroot/stdout.expected $testroot/stdout
1016 ret="$?"
1017 if [ "$ret" != "0" ]; then
1018 diff -u $testroot/stdout.expected $testroot/stdout
1019 test_done "$testroot" "$ret"
1020 return 1
1023 echo "modified delta on branch" > $testroot/content.expected
1024 cat $testroot/wt/gamma/delta > $testroot/content
1025 cmp -s $testroot/content.expected $testroot/content
1026 ret="$?"
1027 if [ "$ret" != "0" ]; then
1028 diff -u $testroot/content.expected $testroot/content
1029 test_done "$testroot" "$ret"
1030 return 1
1033 echo "modified alpha on master" > $testroot/content.expected
1034 cat $testroot/wt/alpha > $testroot/content
1035 cmp -s $testroot/content.expected $testroot/content
1036 ret="$?"
1037 if [ "$ret" != "0" ]; then
1038 diff -u $testroot/content.expected $testroot/content
1039 test_done "$testroot" "$ret"
1040 return 1
1043 if [ -e $testroot/wt/epsilon ]; then
1044 echo "parent of removed zeta still exists on disk" >&2
1045 test_done "$testroot" "1"
1046 return 1
1049 (cd $testroot/wt && got status > $testroot/stdout)
1051 echo -n > $testroot/stdout.expected
1052 cmp -s $testroot/stdout.expected $testroot/stdout
1053 ret="$?"
1054 if [ "$ret" != "0" ]; then
1055 diff -u $testroot/stdout.expected $testroot/stdout
1056 test_done "$testroot" "$ret"
1057 return 1
1060 (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
1061 echo "commit $new_commit2 (newbranch)" > $testroot/stdout.expected
1062 echo "commit $new_commit1" >> $testroot/stdout.expected
1063 echo "commit $master_commit (master)" >> $testroot/stdout.expected
1064 cmp -s $testroot/stdout.expected $testroot/stdout
1065 ret="$?"
1066 if [ "$ret" != "0" ]; then
1067 diff -u $testroot/stdout.expected $testroot/stdout
1069 test_done "$testroot" "$ret"
1072 test_rebase_delete_missing_file() {
1073 local testroot=`test_init rebase_delete_missing_file`
1075 mkdir -p $testroot/repo/d/f/g
1076 echo "new file" > $testroot/repo/d/f/g/new
1077 (cd $testroot/repo && git add d/f/g/new)
1078 git_commit $testroot/repo -m "adding a subdir"
1079 local commit0=`git_show_head $testroot/repo`
1081 got br -r $testroot/repo -c master newbranch
1083 got checkout -b newbranch $testroot/repo $testroot/wt > /dev/null
1085 echo "modified delta on branch" > $testroot/wt/gamma/delta
1086 (cd $testroot/wt && got commit \
1087 -m "committing to delta on newbranch" > /dev/null)
1089 (cd $testroot/wt && got rm beta d/f/g/new > /dev/null)
1090 (cd $testroot/wt && got commit \
1091 -m "removing beta and d/f/g/new on newbranch" > /dev/null)
1093 (cd $testroot/repo && git checkout -q newbranch)
1094 local orig_commit1=`git_show_parent_commit $testroot/repo`
1095 local orig_commit2=`git_show_head $testroot/repo`
1097 (cd $testroot/wt && got update -b master > /dev/null)
1098 (cd $testroot/wt && got rm beta d/f/g/new > /dev/null)
1099 (cd $testroot/wt && got commit \
1100 -m "removing beta and d/f/g/new on master" > /dev/null)
1102 (cd $testroot/repo && git checkout -q master)
1103 local master_commit=`git_show_head $testroot/repo`
1105 (cd $testroot/wt && got update -b master > /dev/null)
1106 (cd $testroot/wt && got rebase newbranch > $testroot/stdout)
1108 (cd $testroot/repo && git checkout -q newbranch)
1109 local new_commit1=`git_show_head $testroot/repo`
1111 local short_orig_commit1=`trim_obj_id 28 $orig_commit1`
1112 local short_orig_commit2=`trim_obj_id 28 $orig_commit2`
1113 local short_new_commit1=`trim_obj_id 28 $new_commit1`
1115 echo "G gamma/delta" >> $testroot/stdout.expected
1116 echo -n "$short_orig_commit1 -> $short_new_commit1" \
1117 >> $testroot/stdout.expected
1118 echo ": committing to delta on newbranch" >> $testroot/stdout.expected
1119 echo "! beta" >> $testroot/stdout.expected
1120 echo "! d/f/g/new" >> $testroot/stdout.expected
1121 echo -n "$short_orig_commit2 -> no-op change" \
1122 >> $testroot/stdout.expected
1123 echo ": removing beta and d/f/g/new on newbranch" \
1124 >> $testroot/stdout.expected
1125 echo "Switching work tree to refs/heads/newbranch" \
1126 >> $testroot/stdout.expected
1128 cmp -s $testroot/stdout.expected $testroot/stdout
1129 ret="$?"
1130 if [ "$ret" != "0" ]; then
1131 diff -u $testroot/stdout.expected $testroot/stdout
1132 test_done "$testroot" "$ret"
1133 return 1
1136 echo "modified delta on branch" > $testroot/content.expected
1137 cat $testroot/wt/gamma/delta > $testroot/content
1138 cmp -s $testroot/content.expected $testroot/content
1139 ret="$?"
1140 if [ "$ret" != "0" ]; then
1141 diff -u $testroot/content.expected $testroot/content
1142 test_done "$testroot" "$ret"
1143 return 1
1146 if [ -e $testroot/wt/beta ]; then
1147 echo "removed file beta still exists on disk" >&2
1148 test_done "$testroot" "1"
1149 return 1
1152 (cd $testroot/wt && got status > $testroot/stdout)
1154 echo -n > $testroot/stdout.expected
1155 cmp -s $testroot/stdout.expected $testroot/stdout
1156 ret="$?"
1157 if [ "$ret" != "0" ]; then
1158 diff -u $testroot/stdout.expected $testroot/stdout
1159 test_done "$testroot" "$ret"
1160 return 1
1163 (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
1164 echo "commit $new_commit1 (newbranch)" > $testroot/stdout.expected
1165 echo "commit $master_commit (master)" >> $testroot/stdout.expected
1166 echo "commit $commit0" >> $testroot/stdout.expected
1167 cmp -s $testroot/stdout.expected $testroot/stdout
1168 ret="$?"
1169 if [ "$ret" != "0" ]; then
1170 diff -u $testroot/stdout.expected $testroot/stdout
1172 test_done "$testroot" "$ret"
1175 test_rebase_rm_add_rm_file() {
1176 local testroot=`test_init rebase_rm_add_rm_file`
1178 (cd $testroot/repo && git checkout -q -b newbranch)
1179 (cd $testroot/repo && git rm -q beta)
1180 git_commit $testroot/repo -m "removing beta from newbranch"
1181 local orig_commit1=`git_show_head $testroot/repo`
1183 echo 'restored beta' > $testroot/repo/beta
1184 (cd $testroot/repo && git add beta)
1185 git_commit $testroot/repo -m "restoring beta on newbranch"
1186 local orig_commit2=`git_show_head $testroot/repo`
1188 (cd $testroot/repo && git rm -q beta)
1189 git_commit $testroot/repo -m "removing beta from newbranch again"
1190 local orig_commit3=`git_show_head $testroot/repo`
1192 (cd $testroot/repo && git checkout -q master)
1193 echo "modified zeta on master" > $testroot/repo/epsilon/zeta
1194 git_commit $testroot/repo -m "committing to zeta on master"
1195 local master_commit=`git_show_head $testroot/repo`
1197 got checkout $testroot/repo $testroot/wt > /dev/null
1198 ret="$?"
1199 if [ "$ret" != "0" ]; then
1200 test_done "$testroot" "$ret"
1201 return 1
1204 (cd $testroot/wt && got rebase newbranch > $testroot/stdout)
1206 # this would error out with 'got: file index is corrupt'
1207 (cd $testroot/wt && got status > /dev/null)
1208 ret="$?"
1209 if [ "$ret" != "0" ]; then
1210 echo "got status command failed unexpectedly" >&2
1211 test_done "$testroot" "$ret"
1212 return 1
1215 (cd $testroot/repo && git checkout -q newbranch)
1216 local new_commit3=`git_show_head $testroot/repo`
1217 local new_commit2=`git_show_parent_commit $testroot/repo`
1218 local new_commit1=`git_show_parent_commit $testroot/repo $new_commit2`
1220 (cd $testroot/repo && git checkout -q newbranch)
1222 local short_orig_commit1=`trim_obj_id 28 $orig_commit1`
1223 local short_orig_commit2=`trim_obj_id 28 $orig_commit2`
1224 local short_orig_commit3=`trim_obj_id 28 $orig_commit3`
1225 local short_new_commit1=`trim_obj_id 28 $new_commit1`
1226 local short_new_commit2=`trim_obj_id 28 $new_commit2`
1227 local short_new_commit3=`trim_obj_id 28 $new_commit3`
1229 echo "D beta" > $testroot/stdout.expected
1230 echo -n "$short_orig_commit1 -> $short_new_commit1" \
1231 >> $testroot/stdout.expected
1232 echo ": removing beta from newbranch" >> $testroot/stdout.expected
1233 echo "A beta" >> $testroot/stdout.expected
1234 echo -n "$short_orig_commit2 -> $short_new_commit2" \
1235 >> $testroot/stdout.expected
1236 echo ": restoring beta on newbranch" >> $testroot/stdout.expected
1237 echo "D beta" >> $testroot/stdout.expected
1238 echo -n "$short_orig_commit3 -> $short_new_commit3" \
1239 >> $testroot/stdout.expected
1240 echo ": removing beta from newbranch again" >> $testroot/stdout.expected
1241 echo "Switching work tree to refs/heads/newbranch" \
1242 >> $testroot/stdout.expected
1244 cmp -s $testroot/stdout.expected $testroot/stdout
1245 ret="$?"
1246 if [ "$ret" != "0" ]; then
1247 diff -u $testroot/stdout.expected $testroot/stdout
1248 test_done "$testroot" "$ret"
1249 return 1
1252 (cd $testroot/wt && got status > $testroot/stdout)
1253 ret="$?"
1254 if [ "$ret" != "0" ]; then
1255 echo "got status command failed unexpectedly" >&2
1256 test_done "$testroot" "$ret"
1257 return 1
1260 echo -n > $testroot/stdout.expected
1261 cmp -s $testroot/stdout.expected $testroot/stdout
1262 ret="$?"
1263 if [ "$ret" != "0" ]; then
1264 diff -u $testroot/stdout.expected $testroot/stdout
1265 test_done "$testroot" "$ret"
1266 return 1
1269 (cd $testroot/wt && got log -l4 | grep ^commit > $testroot/stdout)
1270 echo "commit $new_commit3 (newbranch)" > $testroot/stdout.expected
1271 echo "commit $new_commit2" >> $testroot/stdout.expected
1272 echo "commit $new_commit1" >> $testroot/stdout.expected
1273 echo "commit $master_commit (master)" >> $testroot/stdout.expected
1274 cmp -s $testroot/stdout.expected $testroot/stdout
1275 ret="$?"
1276 if [ "$ret" != "0" ]; then
1277 diff -u $testroot/stdout.expected $testroot/stdout
1279 test_done "$testroot" "$ret"
1282 test_parseargs "$@"
1283 run_test test_rebase_basic
1284 run_test test_rebase_ancestry_check
1285 run_test test_rebase_continue
1286 run_test test_rebase_abort
1287 run_test test_rebase_no_op_change
1288 run_test test_rebase_in_progress
1289 run_test test_rebase_path_prefix
1290 run_test test_rebase_preserves_logmsg
1291 run_test test_rebase_no_commits_to_rebase
1292 run_test test_rebase_forward
1293 run_test test_rebase_out_of_date
1294 run_test test_rebase_trims_empty_dir
1295 run_test test_rebase_delete_missing_file
1296 run_test test_rebase_rm_add_rm_file