Blob


1 #!/bin/sh
2 #
3 # Copyright (c) 2019 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 function 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 fi
136 test_done "$testroot" "$ret"
139 function test_rebase_ancestry_check {
140 local testroot=`test_init rebase_ancestry_check`
142 got checkout $testroot/repo $testroot/wt > /dev/null
143 ret="$?"
144 if [ "$ret" != "0" ]; then
145 test_done "$testroot" "$ret"
146 return 1
147 fi
149 (cd $testroot/repo && git checkout -q -b newbranch)
150 echo "modified delta on branch" > $testroot/repo/gamma/delta
151 git_commit $testroot/repo -m "committing to delta on newbranch"
153 (cd $testroot/wt && got rebase newbranch > $testroot/stdout \
154 2> $testroot/stderr)
156 echo -n > $testroot/stdout.expected
157 cmp -s $testroot/stdout.expected $testroot/stdout
158 ret="$?"
159 if [ "$ret" != "0" ]; then
160 diff -u $testroot/stdout.expected $testroot/stdout
161 test_done "$testroot" "$ret"
162 return 1
163 fi
165 echo -n "got: specified branch resolves to a commit " \
166 > $testroot/stderr.expected
167 echo "which is already contained in work tree's branch" \
168 >> $testroot/stderr.expected
169 cmp -s $testroot/stderr.expected $testroot/stderr
170 ret="$?"
171 if [ "$ret" != "0" ]; then
172 diff -u $testroot/stderr.expected $testroot/stderr
173 fi
174 test_done "$testroot" "$ret"
177 function test_rebase_continue {
178 local testroot=`test_init rebase_continue`
180 (cd $testroot/repo && git checkout -q -b newbranch)
181 echo "modified alpha on branch" > $testroot/repo/alpha
182 git_commit $testroot/repo -m "committing to alpha on newbranch"
183 local orig_commit1=`git_show_head $testroot/repo`
185 (cd $testroot/repo && git checkout -q master)
186 echo "modified alpha on master" > $testroot/repo/alpha
187 git_commit $testroot/repo -m "committing to alpha on master"
188 local master_commit=`git_show_head $testroot/repo`
190 got checkout $testroot/repo $testroot/wt > /dev/null
191 ret="$?"
192 if [ "$ret" != "0" ]; then
193 test_done "$testroot" "$ret"
194 return 1
195 fi
197 (cd $testroot/wt && got rebase newbranch > $testroot/stdout \
198 2> $testroot/stderr)
200 echo "C alpha" > $testroot/stdout.expected
201 cmp -s $testroot/stdout.expected $testroot/stdout
202 ret="$?"
203 if [ "$ret" != "0" ]; then
204 diff -u $testroot/stdout.expected $testroot/stdout
205 test_done "$testroot" "$ret"
206 return 1
207 fi
209 echo "got: conflicts must be resolved before rebasing can continue" \
210 > $testroot/stderr.expected
211 cmp -s $testroot/stderr.expected $testroot/stderr
212 ret="$?"
213 if [ "$ret" != "0" ]; then
214 diff -u $testroot/stderr.expected $testroot/stderr
215 test_done "$testroot" "$ret"
216 return 1
217 fi
219 echo "<<<<<<< commit $orig_commit1" > $testroot/content.expected
220 echo "modified alpha on branch" >> $testroot/content.expected
221 echo "=======" >> $testroot/content.expected
222 echo "modified alpha on master" >> $testroot/content.expected
223 echo '>>>>>>> alpha' >> $testroot/content.expected
224 cat $testroot/wt/alpha > $testroot/content
225 cmp -s $testroot/content.expected $testroot/content
226 ret="$?"
227 if [ "$ret" != "0" ]; then
228 diff -u $testroot/content.expected $testroot/content
229 test_done "$testroot" "$ret"
230 return 1
231 fi
233 (cd $testroot/wt && got status > $testroot/stdout)
235 echo "C alpha" > $testroot/stdout.expected
236 cmp -s $testroot/stdout.expected $testroot/stdout
237 ret="$?"
238 if [ "$ret" != "0" ]; then
239 diff -u $testroot/stdout.expected $testroot/stdout
240 test_done "$testroot" "$ret"
241 return 1
242 fi
244 # resolve the conflict
245 echo "modified alpha on branch and master" > $testroot/wt/alpha
247 (cd $testroot/wt && got rebase -c > $testroot/stdout)
249 (cd $testroot/repo && git checkout -q newbranch)
250 local new_commit1=`git_show_head $testroot/repo`
252 local short_orig_commit1=`trim_obj_id 28 $orig_commit1`
253 local short_new_commit1=`trim_obj_id 28 $new_commit1`
255 echo -n "$short_orig_commit1 -> $short_new_commit1" \
256 > $testroot/stdout.expected
257 echo ": committing to alpha on newbranch" >> $testroot/stdout.expected
258 echo "Switching work tree to refs/heads/newbranch" \
259 >> $testroot/stdout.expected
261 cmp -s $testroot/stdout.expected $testroot/stdout
262 ret="$?"
263 if [ "$ret" != "0" ]; then
264 diff -u $testroot/stdout.expected $testroot/stdout
265 test_done "$testroot" "$ret"
266 return 1
267 fi
270 (cd $testroot/wt && got log -l2 | grep ^commit > $testroot/stdout)
271 echo "commit $new_commit1 (newbranch)" > $testroot/stdout.expected
272 echo "commit $master_commit (master)" >> $testroot/stdout.expected
273 cmp -s $testroot/stdout.expected $testroot/stdout
274 ret="$?"
275 if [ "$ret" != "0" ]; then
276 diff -u $testroot/stdout.expected $testroot/stdout
277 fi
278 test_done "$testroot" "$ret"
281 function test_rebase_abort {
282 local testroot=`test_init rebase_abort`
284 local init_commit=`git_show_head $testroot/repo`
286 (cd $testroot/repo && git checkout -q -b newbranch)
287 echo "modified alpha on branch" > $testroot/repo/alpha
288 git_commit $testroot/repo -m "committing to alpha on newbranch"
289 local orig_commit1=`git_show_head $testroot/repo`
291 (cd $testroot/repo && git checkout -q master)
292 echo "modified alpha on master" > $testroot/repo/alpha
293 git_commit $testroot/repo -m "committing to alpha on master"
294 local master_commit=`git_show_head $testroot/repo`
296 got checkout $testroot/repo $testroot/wt > /dev/null
297 ret="$?"
298 if [ "$ret" != "0" ]; then
299 test_done "$testroot" "$ret"
300 return 1
301 fi
303 (cd $testroot/wt && got rebase newbranch > $testroot/stdout \
304 2> $testroot/stderr)
306 echo "C alpha" > $testroot/stdout.expected
307 cmp -s $testroot/stdout.expected $testroot/stdout
308 ret="$?"
309 if [ "$ret" != "0" ]; then
310 diff -u $testroot/stdout.expected $testroot/stdout
311 test_done "$testroot" "$ret"
312 return 1
313 fi
315 echo "got: conflicts must be resolved before rebasing can continue" \
316 > $testroot/stderr.expected
317 cmp -s $testroot/stderr.expected $testroot/stderr
318 ret="$?"
319 if [ "$ret" != "0" ]; then
320 diff -u $testroot/stderr.expected $testroot/stderr
321 test_done "$testroot" "$ret"
322 return 1
323 fi
325 echo "<<<<<<< commit $orig_commit1" > $testroot/content.expected
326 echo "modified alpha on branch" >> $testroot/content.expected
327 echo "=======" >> $testroot/content.expected
328 echo "modified alpha on master" >> $testroot/content.expected
329 echo '>>>>>>> alpha' >> $testroot/content.expected
330 cat $testroot/wt/alpha > $testroot/content
331 cmp -s $testroot/content.expected $testroot/content
332 ret="$?"
333 if [ "$ret" != "0" ]; then
334 diff -u $testroot/content.expected $testroot/content
335 test_done "$testroot" "$ret"
336 return 1
337 fi
339 (cd $testroot/wt && got status > $testroot/stdout)
341 echo "C alpha" > $testroot/stdout.expected
342 cmp -s $testroot/stdout.expected $testroot/stdout
343 ret="$?"
344 if [ "$ret" != "0" ]; then
345 diff -u $testroot/stdout.expected $testroot/stdout
346 test_done "$testroot" "$ret"
347 return 1
348 fi
350 (cd $testroot/wt && got rebase -a > $testroot/stdout)
352 (cd $testroot/repo && git checkout -q newbranch)
354 echo "Switching work tree to refs/heads/master" \
355 > $testroot/stdout.expected
356 echo 'R alpha' >> $testroot/stdout.expected
357 echo "Rebase of refs/heads/newbranch aborted" \
358 >> $testroot/stdout.expected
360 cmp -s $testroot/stdout.expected $testroot/stdout
361 ret="$?"
362 if [ "$ret" != "0" ]; then
363 diff -u $testroot/stdout.expected $testroot/stdout
364 test_done "$testroot" "$ret"
365 return 1
366 fi
368 echo "modified alpha on master" > $testroot/content.expected
369 cat $testroot/wt/alpha > $testroot/content
370 cmp -s $testroot/content.expected $testroot/content
371 ret="$?"
372 if [ "$ret" != "0" ]; then
373 diff -u $testroot/content.expected $testroot/content
374 test_done "$testroot" "$ret"
375 return 1
376 fi
378 (cd $testroot/wt && got log -l3 -c newbranch \
379 | grep ^commit > $testroot/stdout)
380 echo "commit $orig_commit1 (newbranch)" > $testroot/stdout.expected
381 echo "commit $init_commit" >> $testroot/stdout.expected
382 cmp -s $testroot/stdout.expected $testroot/stdout
383 ret="$?"
384 if [ "$ret" != "0" ]; then
385 diff -u $testroot/stdout.expected $testroot/stdout
386 fi
387 test_done "$testroot" "$ret"
390 function test_rebase_no_op_change {
391 local testroot=`test_init rebase_no_op_change`
392 local init_commit=`git_show_head $testroot/repo`
394 (cd $testroot/repo && git checkout -q -b newbranch)
395 echo "modified alpha on branch" > $testroot/repo/alpha
396 git_commit $testroot/repo -m "committing to alpha on newbranch"
397 local orig_commit1=`git_show_head $testroot/repo`
399 (cd $testroot/repo && git checkout -q master)
400 echo "modified alpha on master" > $testroot/repo/alpha
401 git_commit $testroot/repo -m "committing to alpha on master"
402 local master_commit=`git_show_head $testroot/repo`
404 got checkout $testroot/repo $testroot/wt > /dev/null
405 ret="$?"
406 if [ "$ret" != "0" ]; then
407 test_done "$testroot" "$ret"
408 return 1
409 fi
411 (cd $testroot/wt && got rebase newbranch > $testroot/stdout \
412 2> $testroot/stderr)
414 echo "C alpha" > $testroot/stdout.expected
415 cmp -s $testroot/stdout.expected $testroot/stdout
416 ret="$?"
417 if [ "$ret" != "0" ]; then
418 diff -u $testroot/stdout.expected $testroot/stdout
419 test_done "$testroot" "$ret"
420 return 1
421 fi
423 echo "got: conflicts must be resolved before rebasing can continue" \
424 > $testroot/stderr.expected
425 cmp -s $testroot/stderr.expected $testroot/stderr
426 ret="$?"
427 if [ "$ret" != "0" ]; then
428 diff -u $testroot/stderr.expected $testroot/stderr
429 test_done "$testroot" "$ret"
430 return 1
431 fi
433 echo "<<<<<<< commit $orig_commit1" > $testroot/content.expected
434 echo "modified alpha on branch" >> $testroot/content.expected
435 echo "=======" >> $testroot/content.expected
436 echo "modified alpha on master" >> $testroot/content.expected
437 echo '>>>>>>> alpha' >> $testroot/content.expected
438 cat $testroot/wt/alpha > $testroot/content
439 cmp -s $testroot/content.expected $testroot/content
440 ret="$?"
441 if [ "$ret" != "0" ]; then
442 diff -u $testroot/content.expected $testroot/content
443 test_done "$testroot" "$ret"
444 return 1
445 fi
447 (cd $testroot/wt && got status > $testroot/stdout)
449 echo "C alpha" > $testroot/stdout.expected
450 cmp -s $testroot/stdout.expected $testroot/stdout
451 ret="$?"
452 if [ "$ret" != "0" ]; then
453 diff -u $testroot/stdout.expected $testroot/stdout
454 test_done "$testroot" "$ret"
455 return 1
456 fi
458 # resolve the conflict
459 echo "modified alpha on master" > $testroot/wt/alpha
461 (cd $testroot/wt && got rebase -c > $testroot/stdout)
463 (cd $testroot/repo && git checkout -q newbranch)
464 local new_commit1=`git_show_head $testroot/repo`
466 local short_orig_commit1=`trim_obj_id 28 $orig_commit1`
468 echo -n "$short_orig_commit1 -> no-op change" \
469 > $testroot/stdout.expected
470 echo ": committing to alpha on newbranch" >> $testroot/stdout.expected
471 echo "Switching work tree to refs/heads/newbranch" \
472 >> $testroot/stdout.expected
474 cmp -s $testroot/stdout.expected $testroot/stdout
475 ret="$?"
476 if [ "$ret" != "0" ]; then
477 diff -u $testroot/stdout.expected $testroot/stdout
478 test_done "$testroot" "$ret"
479 return 1
480 fi
483 (cd $testroot/wt && got log -l2 | grep ^commit > $testroot/stdout)
484 echo "commit $master_commit (master, newbranch)" \
485 > $testroot/stdout.expected
486 echo "commit $init_commit" >> $testroot/stdout.expected
487 cmp -s $testroot/stdout.expected $testroot/stdout
488 ret="$?"
489 if [ "$ret" != "0" ]; then
490 diff -u $testroot/stdout.expected $testroot/stdout
491 fi
492 test_done "$testroot" "$ret"
495 function test_rebase_in_progress {
496 local testroot=`test_init rebase_in_progress`
497 local init_commit=`git_show_head $testroot/repo`
499 (cd $testroot/repo && git checkout -q -b newbranch)
500 echo "modified alpha on branch" > $testroot/repo/alpha
501 git_commit $testroot/repo -m "committing to alpha on newbranch"
502 local orig_commit1=`git_show_head $testroot/repo`
504 (cd $testroot/repo && git checkout -q master)
505 echo "modified alpha on master" > $testroot/repo/alpha
506 git_commit $testroot/repo -m "committing to alpha on master"
507 local master_commit=`git_show_head $testroot/repo`
509 got checkout $testroot/repo $testroot/wt > /dev/null
510 ret="$?"
511 if [ "$ret" != "0" ]; then
512 test_done "$testroot" "$ret"
513 return 1
514 fi
516 (cd $testroot/wt && got rebase newbranch > $testroot/stdout \
517 2> $testroot/stderr)
519 echo "C alpha" > $testroot/stdout.expected
520 cmp -s $testroot/stdout.expected $testroot/stdout
521 ret="$?"
522 if [ "$ret" != "0" ]; then
523 diff -u $testroot/stdout.expected $testroot/stdout
524 test_done "$testroot" "$ret"
525 return 1
526 fi
528 echo "got: conflicts must be resolved before rebasing can continue" \
529 > $testroot/stderr.expected
530 cmp -s $testroot/stderr.expected $testroot/stderr
531 ret="$?"
532 if [ "$ret" != "0" ]; then
533 diff -u $testroot/stderr.expected $testroot/stderr
534 test_done "$testroot" "$ret"
535 return 1
536 fi
538 echo "<<<<<<< commit $orig_commit1" > $testroot/content.expected
539 echo "modified alpha on branch" >> $testroot/content.expected
540 echo "=======" >> $testroot/content.expected
541 echo "modified alpha on master" >> $testroot/content.expected
542 echo '>>>>>>> alpha' >> $testroot/content.expected
543 cat $testroot/wt/alpha > $testroot/content
544 cmp -s $testroot/content.expected $testroot/content
545 ret="$?"
546 if [ "$ret" != "0" ]; then
547 diff -u $testroot/content.expected $testroot/content
548 test_done "$testroot" "$ret"
549 return 1
550 fi
552 (cd $testroot/wt && got status > $testroot/stdout)
554 echo "C alpha" > $testroot/stdout.expected
555 cmp -s $testroot/stdout.expected $testroot/stdout
556 ret="$?"
557 if [ "$ret" != "0" ]; then
558 diff -u $testroot/stdout.expected $testroot/stdout
559 test_done "$testroot" "$ret"
560 return 1
561 fi
563 for cmd in update commit; do
564 (cd $testroot/wt && got $cmd > $testroot/stdout \
565 2> $testroot/stderr)
567 echo -n > $testroot/stdout.expected
568 cmp -s $testroot/stdout.expected $testroot/stdout
569 ret="$?"
570 if [ "$ret" != "0" ]; then
571 diff -u $testroot/stdout.expected $testroot/stdout
572 test_done "$testroot" "$ret"
573 return 1
574 fi
576 echo -n "got: a rebase operation is in progress in this " \
577 > $testroot/stderr.expected
578 echo "work tree and must be continued or aborted first" \
579 >> $testroot/stderr.expected
580 cmp -s $testroot/stderr.expected $testroot/stderr
581 ret="$?"
582 if [ "$ret" != "0" ]; then
583 diff -u $testroot/stderr.expected $testroot/stderr
584 test_done "$testroot" "$ret"
585 return 1
586 fi
587 done
589 test_done "$testroot" "$ret"
592 function test_rebase_path_prefix {
593 local testroot=`test_init rebase_path_prefix`
595 (cd $testroot/repo && git checkout -q -b newbranch)
596 echo "modified delta on branch" > $testroot/repo/gamma/delta
597 git_commit $testroot/repo -m "committing to delta on newbranch"
599 local orig_commit1=`git_show_parent_commit $testroot/repo`
600 local orig_commit2=`git_show_head $testroot/repo`
602 (cd $testroot/repo && git checkout -q master)
603 echo "modified zeta on master" > $testroot/repo/epsilon/zeta
604 git_commit $testroot/repo -m "committing to zeta on master"
605 local master_commit=`git_show_head $testroot/repo`
607 got checkout -p epsilon $testroot/repo $testroot/wt > /dev/null
608 ret="$?"
609 if [ "$ret" != "0" ]; then
610 test_done "$testroot" "$ret"
611 return 1
612 fi
614 (cd $testroot/wt && got rebase newbranch \
615 > $testroot/stdout 2> $testroot/stderr)
617 echo -n > $testroot/stdout.expected
618 cmp -s $testroot/stdout.expected $testroot/stdout
619 ret="$?"
620 if [ "$ret" != "0" ]; then
621 diff -u $testroot/stdout.expected $testroot/stdout
622 test_done "$testroot" "$ret"
623 return 1
624 fi
626 echo -n "got: cannot rebase branch which contains changes outside " \
627 > $testroot/stderr.expected
628 echo "of this work tree's path prefix" >> $testroot/stderr.expected
629 cmp -s $testroot/stderr.expected $testroot/stderr
630 ret="$?"
631 if [ "$ret" != "0" ]; then
632 diff -u $testroot/stderr.expected $testroot/stderr
633 fi
634 test_done "$testroot" "$ret"
637 function test_rebase_preserves_logmsg {
638 local testroot=`test_init rebase_preserves_logmsg`
640 (cd $testroot/repo && git checkout -q -b newbranch)
641 echo "modified delta on branch" > $testroot/repo/gamma/delta
642 git_commit $testroot/repo -m "modified delta on newbranch"
644 echo "modified alpha on branch" > $testroot/repo/alpha
645 git_commit $testroot/repo -m "modified alpha on newbranch"
647 (cd $testroot/repo && got log -c newbranch -l2 | grep -v ^date: \
648 > $testroot/log.expected)
650 local orig_commit1=`git_show_parent_commit $testroot/repo`
651 local orig_commit2=`git_show_head $testroot/repo`
653 (cd $testroot/repo && git checkout -q master)
654 echo "modified zeta on master" > $testroot/repo/epsilon/zeta
655 git_commit $testroot/repo -m "committing to zeta on master"
656 local master_commit=`git_show_head $testroot/repo`
658 got checkout $testroot/repo $testroot/wt > /dev/null
659 ret="$?"
660 if [ "$ret" != "0" ]; then
661 test_done "$testroot" "$ret"
662 return 1
663 fi
665 (cd $testroot/wt && got rebase newbranch > /dev/null \
666 2> $testroot/stderr)
668 (cd $testroot/repo && git checkout -q newbranch)
669 local new_commit1=`git_show_parent_commit $testroot/repo`
670 local new_commit2=`git_show_head $testroot/repo`
672 echo -n > $testroot/stderr.expected
673 cmp -s $testroot/stderr.expected $testroot/stderr
674 ret="$?"
675 if [ "$ret" != "0" ]; then
676 diff -u $testroot/stderr.expected $testroot/stderr
677 test_done "$testroot" "$ret"
678 return 1
679 fi
681 (cd $testroot/wt && got log -c newbranch -l2 | grep -v ^date: \
682 > $testroot/log)
683 sed -i -e "s/$orig_commit1/$new_commit1/" $testroot/log.expected
684 sed -i -e "s/$orig_commit2/$new_commit2/" $testroot/log.expected
685 cmp -s $testroot/log.expected $testroot/log
686 ret="$?"
687 if [ "$ret" != "0" ]; then
688 diff -u $testroot/log.expected $testroot/log
689 fi
691 test_done "$testroot" "$ret"
694 run_test test_rebase_basic
695 run_test test_rebase_ancestry_check
696 run_test test_rebase_continue
697 run_test test_rebase_abort
698 run_test test_rebase_no_op_change
699 run_test test_rebase_in_progress
700 run_test test_rebase_path_prefix
701 run_test test_rebase_preserves_logmsg