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`
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
44 ret=$?
45 if [ $ret -ne 0 ]; then
46 test_done "$testroot" "$ret"
47 return 1
48 fi
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
77 ret=$?
78 if [ $ret -ne 0 ]; then
79 diff -u $testroot/stdout.expected $testroot/stdout
80 test_done "$testroot" "$ret"
81 return 1
82 fi
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
87 ret=$?
88 if [ $ret -ne 0 ]; then
89 diff -u $testroot/content.expected $testroot/content
90 test_done "$testroot" "$ret"
91 return 1
92 fi
94 echo "modified alpha on branch" > $testroot/content.expected
95 cat $testroot/wt/alpha > $testroot/content
96 cmp -s $testroot/content.expected $testroot/content
97 ret=$?
98 if [ $ret -ne 0 ]; then
99 diff -u $testroot/content.expected $testroot/content
100 test_done "$testroot" "$ret"
101 return 1
102 fi
104 if [ -e $testroot/wt/beta ]; then
105 echo "removed file beta still exists on disk" >&2
106 test_done "$testroot" "1"
107 return 1
108 fi
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
113 ret=$?
114 if [ $ret -ne 0 ]; then
115 diff -u $testroot/content.expected $testroot/content
116 test_done "$testroot" "$ret"
117 return 1
118 fi
120 (cd $testroot/wt && got status > $testroot/stdout)
122 echo -n > $testroot/stdout.expected
123 cmp -s $testroot/stdout.expected $testroot/stdout
124 ret=$?
125 if [ $ret -ne 0 ]; then
126 diff -u $testroot/stdout.expected $testroot/stdout
127 test_done "$testroot" "$ret"
128 return 1
129 fi
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
136 ret=$?
137 if [ $ret -ne 0 ]; then
138 diff -u $testroot/stdout.expected $testroot/stdout
139 test_done "$testroot" "$ret"
140 return 1
141 fi
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
147 ret=$?
148 if [ $ret -ne 0 ]; then
149 diff -u $testroot/stdout.expected $testroot/stdout
150 test_done "$testroot" "$ret"
151 return 1
152 fi
154 # We should have a backup of old commits
155 (cd $testroot/repo && got rebase -l > $testroot/stdout)
156 d_orig2=`date -u -r $orig_author_time2 +"%a %b %e %X %Y UTC"`
157 d_new2=`date -u -r $new_author_time2 +"%G-%m-%d"`
158 d_0=`date -u -r $commit0_author_time +"%G-%m-%d"`
159 cat > $testroot/stdout.expected <<EOF
160 -----------------------------------------------
161 commit $orig_commit2 (formerly newbranch)
162 from: $GOT_AUTHOR
163 date: $d_orig2
165 committing more changes on newbranch
167 has become commit $new_commit2 (newbranch)
168 $d_new2 $GOT_AUTHOR_11 committing more changes on newbranch
169 history forked at $commit0
170 $d_0 $GOT_AUTHOR_11 adding the test tree
171 EOF
172 cmp -s $testroot/stdout.expected $testroot/stdout
173 ret=$?
174 if [ $ret -ne 0 ]; then
175 diff -u $testroot/stdout.expected $testroot/stdout
176 test_done "$testroot" "$ret"
177 return 1
178 fi
180 # Asking for backups of a branch which has none should yield an error
181 (cd $testroot/repo && got rebase -l master \
182 > $testroot/stdout 2> $testroot/stderr)
183 echo -n > $testroot/stdout.expected
184 echo "got: refs/got/backup/rebase/master/: no such reference found" \
185 > $testroot/stderr.expected
186 cmp -s $testroot/stdout.expected $testroot/stdout
187 ret=$?
188 if [ $ret -ne 0 ]; then
189 diff -u $testroot/stdout.expected $testroot/stdout
190 test_done "$testroot" "$ret"
191 return 1
192 fi
193 cmp -s $testroot/stderr.expected $testroot/stderr
194 ret=$?
195 if [ $ret -ne 0 ]; then
196 diff -u $testroot/stderr.expected $testroot/stderr
197 test_done "$testroot" "$ret"
198 return 1
199 fi
201 # Delete all backup refs
202 (cd $testroot/repo && got rebase -X \
203 > $testroot/stdout 2> $testroot/stderr)
204 echo -n "Deleted refs/got/backup/rebase/newbranch/$new_commit2: " \
205 > $testroot/stdout.expected
206 echo "$orig_commit2" >> $testroot/stdout.expected
207 echo -n > $testroot/stderr.expected
208 cmp -s $testroot/stdout.expected $testroot/stdout
209 ret=$?
210 if [ $ret -ne 0 ]; then
211 diff -u $testroot/stdout.expected $testroot/stdout
212 test_done "$testroot" "$ret"
213 return 1
214 fi
215 cmp -s $testroot/stderr.expected $testroot/stderr
216 ret=$?
217 if [ $ret -ne 0 ]; then
218 diff -u $testroot/stderr.expected $testroot/stderr
219 test_done "$testroot" "$ret"
220 return 1
221 fi
223 (cd $testroot/repo && got rebase -l > $testroot/stdout)
224 echo -n > $testroot/stdout.expected
225 cmp -s $testroot/stdout.expected $testroot/stdout
226 ret=$?
227 if [ $ret -ne 0 ]; then
228 diff -u $testroot/stdout.expected $testroot/stdout
229 fi
230 test_done "$testroot" "$ret"
233 test_rebase_ancestry_check() {
234 local testroot=`test_init rebase_ancestry_check`
236 got checkout $testroot/repo $testroot/wt > /dev/null
237 ret=$?
238 if [ $ret -ne 0 ]; then
239 test_done "$testroot" "$ret"
240 return 1
241 fi
243 (cd $testroot/repo && git checkout -q -b newbranch)
244 echo "modified delta on branch" > $testroot/repo/gamma/delta
245 git_commit $testroot/repo -m "committing to delta on newbranch"
246 local newbranch_id=`git_show_head $testroot/repo`
248 (cd $testroot/wt && got rebase newbranch > $testroot/stdout \
249 2> $testroot/stderr)
251 echo "refs/heads/newbranch is already based on refs/heads/master" \
252 > $testroot/stdout.expected
253 echo "Switching work tree from refs/heads/master to refs/heads/newbranch" \
254 >> $testroot/stdout.expected
255 echo "U gamma/delta" >> $testroot/stdout.expected
256 echo "Updated to refs/heads/newbranch: ${newbranch_id}" \
257 >> $testroot/stdout.expected
258 cmp -s $testroot/stdout.expected $testroot/stdout
259 ret=$?
260 if [ $ret -ne 0 ]; then
261 diff -u $testroot/stdout.expected $testroot/stdout
262 test_done "$testroot" "$ret"
263 return 1
264 fi
266 echo -n > $testroot/stderr.expected
267 cmp -s $testroot/stderr.expected $testroot/stderr
268 ret=$?
269 if [ $ret -ne 0 ]; then
270 diff -u $testroot/stderr.expected $testroot/stderr
271 fi
272 test_done "$testroot" "$ret"
275 test_rebase_continue() {
276 local testroot=`test_init rebase_continue`
277 local init_commit=`git_show_head $testroot/repo`
279 (cd $testroot/repo && git checkout -q -b newbranch)
280 echo "modified alpha on branch" > $testroot/repo/alpha
281 git_commit $testroot/repo -m "committing to alpha on newbranch"
282 local orig_commit1=`git_show_head $testroot/repo`
283 local short_orig_commit1=`trim_obj_id 28 $orig_commit1`
285 (cd $testroot/repo && git checkout -q master)
286 echo "modified alpha on master" > $testroot/repo/alpha
287 git_commit $testroot/repo -m "committing to alpha on master"
288 local master_commit=`git_show_head $testroot/repo`
290 got checkout $testroot/repo $testroot/wt > /dev/null
291 ret=$?
292 if [ $ret -ne 0 ]; then
293 test_done "$testroot" "$ret"
294 return 1
295 fi
297 (cd $testroot/wt && got rebase newbranch > $testroot/stdout \
298 2> $testroot/stderr)
300 echo "C alpha" > $testroot/stdout.expected
301 echo "Files with new merge conflicts: 1" >> $testroot/stdout.expected
302 echo -n "$short_orig_commit1 -> merge conflict" \
303 >> $testroot/stdout.expected
304 echo ": committing to alpha on newbranch" >> $testroot/stdout.expected
305 cmp -s $testroot/stdout.expected $testroot/stdout
306 ret=$?
307 if [ $ret -ne 0 ]; then
308 diff -u $testroot/stdout.expected $testroot/stdout
309 test_done "$testroot" "$ret"
310 return 1
311 fi
313 echo "got: conflicts must be resolved before rebasing can continue" \
314 > $testroot/stderr.expected
315 cmp -s $testroot/stderr.expected $testroot/stderr
316 ret=$?
317 if [ $ret -ne 0 ]; then
318 diff -u $testroot/stderr.expected $testroot/stderr
319 test_done "$testroot" "$ret"
320 return 1
321 fi
323 echo '<<<<<<<' > $testroot/content.expected
324 echo "modified alpha on master" >> $testroot/content.expected
325 echo "||||||| 3-way merge base: commit $init_commit" \
326 >> $testroot/content.expected
327 echo "alpha" >> $testroot/content.expected
328 echo "=======" >> $testroot/content.expected
329 echo "modified alpha on branch" >> $testroot/content.expected
330 echo ">>>>>>> merged change: commit $orig_commit1" \
331 >> $testroot/content.expected
332 cat $testroot/wt/alpha > $testroot/content
333 cmp -s $testroot/content.expected $testroot/content
334 ret=$?
335 if [ $ret -ne 0 ]; then
336 diff -u $testroot/content.expected $testroot/content
337 test_done "$testroot" "$ret"
338 return 1
339 fi
341 (cd $testroot/wt && got status > $testroot/stdout)
343 echo "C alpha" > $testroot/stdout.expected
344 cmp -s $testroot/stdout.expected $testroot/stdout
345 ret=$?
346 if [ $ret -ne 0 ]; then
347 diff -u $testroot/stdout.expected $testroot/stdout
348 test_done "$testroot" "$ret"
349 return 1
350 fi
352 # resolve the conflict
353 echo "modified alpha on branch and master" > $testroot/wt/alpha
355 # test interaction of 'got stage' and rebase -c
356 (cd $testroot/wt && got stage alpha > /dev/null)
357 (cd $testroot/wt && got rebase -c > $testroot/stdout \
358 2> $testroot/stderr)
359 ret=$?
360 if [ $ret -eq 0 ]; then
361 echo "rebase succeeded unexpectedly" >&2
362 test_done "$testroot" "1"
363 return 1
364 fi
365 echo -n "got: work tree contains files with staged changes; " \
366 > $testroot/stderr.expected
367 echo "these changes must be committed or unstaged first" \
368 >> $testroot/stderr.expected
369 cmp -s $testroot/stderr.expected $testroot/stderr
370 ret=$?
371 if [ $ret -ne 0 ]; then
372 diff -u $testroot/stderr.expected $testroot/stderr
373 test_done "$testroot" "$ret"
374 return 1
375 fi
377 (cd $testroot/wt && got unstage alpha > /dev/null)
378 (cd $testroot/wt && got rebase -c > $testroot/stdout)
380 (cd $testroot/repo && git checkout -q newbranch)
381 local new_commit1=`git_show_head $testroot/repo`
382 local short_new_commit1=`trim_obj_id 28 $new_commit1`
384 echo -n "$short_orig_commit1 -> $short_new_commit1" \
385 > $testroot/stdout.expected
386 echo ": committing to alpha on newbranch" >> $testroot/stdout.expected
387 echo "Switching work tree to refs/heads/newbranch" \
388 >> $testroot/stdout.expected
390 cmp -s $testroot/stdout.expected $testroot/stdout
391 ret=$?
392 if [ $ret -ne 0 ]; then
393 diff -u $testroot/stdout.expected $testroot/stdout
394 test_done "$testroot" "$ret"
395 return 1
396 fi
399 (cd $testroot/wt && got log -l2 | grep ^commit > $testroot/stdout)
400 echo "commit $new_commit1 (newbranch)" > $testroot/stdout.expected
401 echo "commit $master_commit (master)" >> $testroot/stdout.expected
402 cmp -s $testroot/stdout.expected $testroot/stdout
403 ret=$?
404 if [ $ret -ne 0 ]; then
405 diff -u $testroot/stdout.expected $testroot/stdout
406 fi
407 test_done "$testroot" "$ret"
410 test_rebase_abort() {
411 local testroot=`test_init rebase_abort`
413 local init_commit=`git_show_head $testroot/repo`
415 (cd $testroot/repo && git checkout -q -b newbranch)
416 echo "modified alpha on branch" > $testroot/repo/alpha
417 git_commit $testroot/repo -m "committing to alpha on newbranch"
418 local orig_commit1=`git_show_head $testroot/repo`
419 local short_orig_commit1=`trim_obj_id 28 $orig_commit1`
421 (cd $testroot/repo && git checkout -q master)
422 echo "modified alpha on master" > $testroot/repo/alpha
423 git_commit $testroot/repo -m "committing to alpha on master"
424 local master_commit=`git_show_head $testroot/repo`
426 got checkout $testroot/repo $testroot/wt > /dev/null
427 ret=$?
428 if [ $ret -ne 0 ]; then
429 test_done "$testroot" "$ret"
430 return 1
431 fi
433 # unrelated unversioned file in work tree
434 touch $testroot/wt/unversioned-file
436 (cd $testroot/wt && got rebase newbranch > $testroot/stdout \
437 2> $testroot/stderr)
439 echo "C alpha" > $testroot/stdout.expected
440 echo "Files with new merge conflicts: 1" >> $testroot/stdout.expected
441 echo -n "$short_orig_commit1 -> merge conflict" \
442 >> $testroot/stdout.expected
443 echo ": committing to alpha on newbranch" >> $testroot/stdout.expected
444 cmp -s $testroot/stdout.expected $testroot/stdout
445 ret=$?
446 if [ $ret -ne 0 ]; then
447 diff -u $testroot/stdout.expected $testroot/stdout
448 test_done "$testroot" "$ret"
449 return 1
450 fi
452 echo "got: conflicts must be resolved before rebasing can continue" \
453 > $testroot/stderr.expected
454 cmp -s $testroot/stderr.expected $testroot/stderr
455 ret=$?
456 if [ $ret -ne 0 ]; then
457 diff -u $testroot/stderr.expected $testroot/stderr
458 test_done "$testroot" "$ret"
459 return 1
460 fi
462 echo '<<<<<<<' > $testroot/content.expected
463 echo "modified alpha on master" >> $testroot/content.expected
464 echo "||||||| 3-way merge base: commit $init_commit" \
465 >> $testroot/content.expected
466 echo "alpha" >> $testroot/content.expected
467 echo "=======" >> $testroot/content.expected
468 echo "modified alpha on branch" >> $testroot/content.expected
469 echo ">>>>>>> merged change: commit $orig_commit1" \
470 >> $testroot/content.expected
471 cat $testroot/wt/alpha > $testroot/content
472 cmp -s $testroot/content.expected $testroot/content
473 ret=$?
474 if [ $ret -ne 0 ]; then
475 diff -u $testroot/content.expected $testroot/content
476 test_done "$testroot" "$ret"
477 return 1
478 fi
480 (cd $testroot/wt && got status > $testroot/stdout)
482 echo "C alpha" > $testroot/stdout.expected
483 echo "? unversioned-file" >> $testroot/stdout.expected
484 cmp -s $testroot/stdout.expected $testroot/stdout
485 ret=$?
486 if [ $ret -ne 0 ]; then
487 diff -u $testroot/stdout.expected $testroot/stdout
488 test_done "$testroot" "$ret"
489 return 1
490 fi
492 (cd $testroot/wt && got rebase -a > $testroot/stdout)
494 (cd $testroot/repo && git checkout -q newbranch)
496 echo "Switching work tree to refs/heads/master" \
497 > $testroot/stdout.expected
498 echo 'R alpha' >> $testroot/stdout.expected
499 echo "Rebase of refs/heads/newbranch aborted" \
500 >> $testroot/stdout.expected
502 cmp -s $testroot/stdout.expected $testroot/stdout
503 ret=$?
504 if [ $ret -ne 0 ]; then
505 diff -u $testroot/stdout.expected $testroot/stdout
506 test_done "$testroot" "$ret"
507 return 1
508 fi
510 echo "modified alpha on master" > $testroot/content.expected
511 cat $testroot/wt/alpha > $testroot/content
512 cmp -s $testroot/content.expected $testroot/content
513 ret=$?
514 if [ $ret -ne 0 ]; then
515 diff -u $testroot/content.expected $testroot/content
516 test_done "$testroot" "$ret"
517 return 1
518 fi
520 (cd $testroot/wt && got log -l3 -c newbranch \
521 | grep ^commit > $testroot/stdout)
522 echo "commit $orig_commit1 (newbranch)" > $testroot/stdout.expected
523 echo "commit $init_commit" >> $testroot/stdout.expected
524 cmp -s $testroot/stdout.expected $testroot/stdout
525 ret=$?
526 if [ $ret -ne 0 ]; then
527 diff -u $testroot/stdout.expected $testroot/stdout
528 fi
529 test_done "$testroot" "$ret"
532 test_rebase_no_op_change() {
533 local testroot=`test_init rebase_no_op_change`
534 local init_commit=`git_show_head $testroot/repo`
536 (cd $testroot/repo && git checkout -q -b newbranch)
537 echo "modified alpha on branch" > $testroot/repo/alpha
538 git_commit $testroot/repo -m "committing to alpha on newbranch"
539 local orig_commit1=`git_show_head $testroot/repo`
540 local short_orig_commit1=`trim_obj_id 28 $orig_commit1`
542 (cd $testroot/repo && git checkout -q master)
543 echo "modified alpha on master" > $testroot/repo/alpha
544 git_commit $testroot/repo -m "committing to alpha on master"
545 local master_commit=`git_show_head $testroot/repo`
547 got checkout $testroot/repo $testroot/wt > /dev/null
548 ret=$?
549 if [ $ret -ne 0 ]; then
550 test_done "$testroot" "$ret"
551 return 1
552 fi
554 (cd $testroot/wt && got rebase newbranch > $testroot/stdout \
555 2> $testroot/stderr)
557 echo "C alpha" > $testroot/stdout.expected
558 echo "Files with new merge conflicts: 1" >> $testroot/stdout.expected
559 echo -n "$short_orig_commit1 -> merge conflict" \
560 >> $testroot/stdout.expected
561 echo ": committing to alpha on newbranch" >> $testroot/stdout.expected
562 cmp -s $testroot/stdout.expected $testroot/stdout
563 ret=$?
564 if [ $ret -ne 0 ]; then
565 diff -u $testroot/stdout.expected $testroot/stdout
566 test_done "$testroot" "$ret"
567 return 1
568 fi
570 echo "got: conflicts must be resolved before rebasing can continue" \
571 > $testroot/stderr.expected
572 cmp -s $testroot/stderr.expected $testroot/stderr
573 ret=$?
574 if [ $ret -ne 0 ]; then
575 diff -u $testroot/stderr.expected $testroot/stderr
576 test_done "$testroot" "$ret"
577 return 1
578 fi
580 echo '<<<<<<<' > $testroot/content.expected
581 echo "modified alpha on master" >> $testroot/content.expected
582 echo "||||||| 3-way merge base: commit $init_commit" \
583 >> $testroot/content.expected
584 echo "alpha" >> $testroot/content.expected
585 echo "=======" >> $testroot/content.expected
586 echo "modified alpha on branch" >> $testroot/content.expected
587 echo ">>>>>>> merged change: commit $orig_commit1" \
588 >> $testroot/content.expected
589 cat $testroot/wt/alpha > $testroot/content
590 cmp -s $testroot/content.expected $testroot/content
591 ret=$?
592 if [ $ret -ne 0 ]; then
593 diff -u $testroot/content.expected $testroot/content
594 test_done "$testroot" "$ret"
595 return 1
596 fi
598 (cd $testroot/wt && got status > $testroot/stdout)
600 echo "C alpha" > $testroot/stdout.expected
601 cmp -s $testroot/stdout.expected $testroot/stdout
602 ret=$?
603 if [ $ret -ne 0 ]; then
604 diff -u $testroot/stdout.expected $testroot/stdout
605 test_done "$testroot" "$ret"
606 return 1
607 fi
609 # resolve the conflict
610 echo "modified alpha on master" > $testroot/wt/alpha
612 (cd $testroot/wt && got rebase -c > $testroot/stdout)
614 (cd $testroot/repo && git checkout -q newbranch)
615 local new_commit1=`git_show_head $testroot/repo`
617 echo -n "$short_orig_commit1 -> no-op change" \
618 > $testroot/stdout.expected
619 echo ": committing to alpha on newbranch" >> $testroot/stdout.expected
620 echo "Switching work tree to refs/heads/newbranch" \
621 >> $testroot/stdout.expected
623 cmp -s $testroot/stdout.expected $testroot/stdout
624 ret=$?
625 if [ $ret -ne 0 ]; then
626 diff -u $testroot/stdout.expected $testroot/stdout
627 test_done "$testroot" "$ret"
628 return 1
629 fi
632 (cd $testroot/wt && got log -l2 | grep ^commit > $testroot/stdout)
633 echo "commit $master_commit (master, newbranch)" \
634 > $testroot/stdout.expected
635 echo "commit $init_commit" >> $testroot/stdout.expected
636 cmp -s $testroot/stdout.expected $testroot/stdout
637 ret=$?
638 if [ $ret -ne 0 ]; then
639 diff -u $testroot/stdout.expected $testroot/stdout
640 fi
641 test_done "$testroot" "$ret"
644 test_rebase_in_progress() {
645 local testroot=`test_init rebase_in_progress`
646 local init_commit=`git_show_head $testroot/repo`
648 (cd $testroot/repo && git checkout -q -b newbranch)
649 echo "modified alpha on branch" > $testroot/repo/alpha
650 git_commit $testroot/repo -m "committing to alpha on newbranch"
651 local orig_commit1=`git_show_head $testroot/repo`
652 local short_orig_commit1=`trim_obj_id 28 $orig_commit1`
654 (cd $testroot/repo && git checkout -q master)
655 echo "modified alpha on master" > $testroot/repo/alpha
656 git_commit $testroot/repo -m "committing to alpha on master"
657 local master_commit=`git_show_head $testroot/repo`
659 got checkout $testroot/repo $testroot/wt > /dev/null
660 ret=$?
661 if [ $ret -ne 0 ]; then
662 test_done "$testroot" "$ret"
663 return 1
664 fi
666 (cd $testroot/wt && got rebase newbranch > $testroot/stdout \
667 2> $testroot/stderr)
669 echo "C alpha" > $testroot/stdout.expected
670 echo "Files with new merge conflicts: 1" >> $testroot/stdout.expected
671 echo -n "$short_orig_commit1 -> merge conflict" \
672 >> $testroot/stdout.expected
673 echo ": committing to alpha on newbranch" >> $testroot/stdout.expected
674 cmp -s $testroot/stdout.expected $testroot/stdout
675 ret=$?
676 if [ $ret -ne 0 ]; then
677 diff -u $testroot/stdout.expected $testroot/stdout
678 test_done "$testroot" "$ret"
679 return 1
680 fi
682 echo "got: conflicts must be resolved before rebasing can continue" \
683 > $testroot/stderr.expected
684 cmp -s $testroot/stderr.expected $testroot/stderr
685 ret=$?
686 if [ $ret -ne 0 ]; then
687 diff -u $testroot/stderr.expected $testroot/stderr
688 test_done "$testroot" "$ret"
689 return 1
690 fi
692 echo '<<<<<<<' > $testroot/content.expected
693 echo "modified alpha on master" >> $testroot/content.expected
694 echo "||||||| 3-way merge base: commit $init_commit" \
695 >> $testroot/content.expected
696 echo "alpha" >> $testroot/content.expected
697 echo "=======" >> $testroot/content.expected
698 echo "modified alpha on branch" >> $testroot/content.expected
699 echo ">>>>>>> merged change: commit $orig_commit1" \
700 >> $testroot/content.expected
701 cat $testroot/wt/alpha > $testroot/content
702 cmp -s $testroot/content.expected $testroot/content
703 ret=$?
704 if [ $ret -ne 0 ]; then
705 diff -u $testroot/content.expected $testroot/content
706 test_done "$testroot" "$ret"
707 return 1
708 fi
710 (cd $testroot/wt && got status > $testroot/stdout)
712 echo "C alpha" > $testroot/stdout.expected
713 cmp -s $testroot/stdout.expected $testroot/stdout
714 ret=$?
715 if [ $ret -ne 0 ]; then
716 diff -u $testroot/stdout.expected $testroot/stdout
717 test_done "$testroot" "$ret"
718 return 1
719 fi
721 for cmd in update commit; do
722 (cd $testroot/wt && got $cmd > $testroot/stdout \
723 2> $testroot/stderr)
725 echo -n > $testroot/stdout.expected
726 cmp -s $testroot/stdout.expected $testroot/stdout
727 ret=$?
728 if [ $ret -ne 0 ]; then
729 diff -u $testroot/stdout.expected $testroot/stdout
730 test_done "$testroot" "$ret"
731 return 1
732 fi
734 echo -n "got: a rebase operation is in progress in this " \
735 > $testroot/stderr.expected
736 echo "work tree and must be continued or aborted first" \
737 >> $testroot/stderr.expected
738 cmp -s $testroot/stderr.expected $testroot/stderr
739 ret=$?
740 if [ $ret -ne 0 ]; then
741 diff -u $testroot/stderr.expected $testroot/stderr
742 test_done "$testroot" "$ret"
743 return 1
744 fi
745 done
747 test_done "$testroot" "$ret"
750 test_rebase_path_prefix() {
751 local testroot=`test_init rebase_path_prefix`
753 (cd $testroot/repo && git checkout -q -b newbranch)
754 echo "modified delta on branch" > $testroot/repo/gamma/delta
755 git_commit $testroot/repo -m "committing to delta on newbranch"
757 local orig_commit1=`git_show_parent_commit $testroot/repo`
758 local orig_commit2=`git_show_head $testroot/repo`
760 (cd $testroot/repo && git checkout -q master)
761 echo "modified zeta on master" > $testroot/repo/epsilon/zeta
762 git_commit $testroot/repo -m "committing to zeta on master"
763 local master_commit=`git_show_head $testroot/repo`
765 got checkout -p epsilon $testroot/repo $testroot/wt > /dev/null
766 ret=$?
767 if [ $ret -ne 0 ]; then
768 test_done "$testroot" "$ret"
769 return 1
770 fi
772 (cd $testroot/wt && got rebase newbranch \
773 > $testroot/stdout 2> $testroot/stderr)
775 echo -n > $testroot/stdout.expected
776 cmp -s $testroot/stdout.expected $testroot/stdout
777 ret=$?
778 if [ $ret -ne 0 ]; then
779 diff -u $testroot/stdout.expected $testroot/stdout
780 test_done "$testroot" "$ret"
781 return 1
782 fi
784 echo -n "got: cannot rebase branch which contains changes outside " \
785 > $testroot/stderr.expected
786 echo "of this work tree's path prefix" >> $testroot/stderr.expected
787 cmp -s $testroot/stderr.expected $testroot/stderr
788 ret=$?
789 if [ $ret -ne 0 ]; then
790 diff -u $testroot/stderr.expected $testroot/stderr
791 test_done "$testroot" "$ret"
792 return 1
793 fi
795 # rebase should succeed when using a complete work tree
796 got checkout $testroot/repo $testroot/wt2 > /dev/null
797 ret=$?
798 if [ $ret -ne 0 ]; then
799 test_done "$testroot" "$ret"
800 return 1
801 fi
803 (cd $testroot/wt2 && got rebase newbranch \
804 > $testroot/stdout 2> $testroot/stderr)
806 (cd $testroot/repo && git checkout -q newbranch)
807 local new_commit1=`git_show_parent_commit $testroot/repo`
808 local new_commit2=`git_show_head $testroot/repo`
810 local short_orig_commit2=`trim_obj_id 28 $orig_commit2`
811 local short_new_commit2=`trim_obj_id 28 $new_commit2`
813 echo "G gamma/delta" > $testroot/stdout.expected
814 echo -n "$short_orig_commit2 -> $short_new_commit2" \
815 >> $testroot/stdout.expected
816 echo ": committing to delta on newbranch" \
817 >> $testroot/stdout.expected
818 echo "Switching work tree to refs/heads/newbranch" \
819 >> $testroot/stdout.expected
821 cmp -s $testroot/stdout.expected $testroot/stdout
822 ret=$?
823 if [ $ret -ne 0 ]; then
824 diff -u $testroot/stdout.expected $testroot/stdout
825 test_done "$testroot" "$ret"
826 return 1
827 fi
829 # the first work tree should remain usable
830 (cd $testroot/wt && got update -b master \
831 > $testroot/stdout 2> $testroot/stderr)
832 ret=$?
833 if [ $ret -ne 0 ]; then
834 echo "update failed unexpectedly" >&2
835 test_done "$testroot" "1"
836 return 1
837 fi
839 echo 'Already up-to-date' > $testroot/stdout.expected
840 cmp -s $testroot/stdout.expected $testroot/stdout
841 ret=$?
842 if [ $ret -ne 0 ]; then
843 diff -u $testroot/stdout.expected $testroot/stdout
844 fi
845 test_done "$testroot" "$ret"
848 test_rebase_preserves_logmsg() {
849 local testroot=`test_init rebase_preserves_logmsg`
851 (cd $testroot/repo && git checkout -q -b newbranch)
852 echo "modified delta on branch" > $testroot/repo/gamma/delta
853 git_commit $testroot/repo -m "modified delta on newbranch"
855 echo "modified alpha on branch" > $testroot/repo/alpha
856 git_commit $testroot/repo -m "modified alpha on newbranch"
858 (cd $testroot/repo && got log -c newbranch -l2 | grep -v ^date: \
859 > $testroot/log.expected)
861 local orig_commit1=`git_show_parent_commit $testroot/repo`
862 local orig_commit2=`git_show_head $testroot/repo`
864 (cd $testroot/repo && git checkout -q master)
865 echo "modified zeta on master" > $testroot/repo/epsilon/zeta
866 git_commit $testroot/repo -m "committing to zeta on master"
867 local master_commit=`git_show_head $testroot/repo`
869 got checkout $testroot/repo $testroot/wt > /dev/null
870 ret=$?
871 if [ $ret -ne 0 ]; then
872 test_done "$testroot" "$ret"
873 return 1
874 fi
876 (cd $testroot/wt && got rebase newbranch > /dev/null \
877 2> $testroot/stderr)
879 (cd $testroot/repo && git checkout -q newbranch)
880 local new_commit1=`git_show_parent_commit $testroot/repo`
881 local new_commit2=`git_show_head $testroot/repo`
883 echo -n > $testroot/stderr.expected
884 cmp -s $testroot/stderr.expected $testroot/stderr
885 ret=$?
886 if [ $ret -ne 0 ]; then
887 diff -u $testroot/stderr.expected $testroot/stderr
888 test_done "$testroot" "$ret"
889 return 1
890 fi
892 (cd $testroot/wt && got log -c newbranch -l2 | grep -v ^date: \
893 > $testroot/log)
894 sed -i -e "s/$orig_commit1/$new_commit1/" $testroot/log.expected
895 sed -i -e "s/$orig_commit2/$new_commit2/" $testroot/log.expected
896 cmp -s $testroot/log.expected $testroot/log
897 ret=$?
898 if [ $ret -ne 0 ]; then
899 diff -u $testroot/log.expected $testroot/log
900 fi
902 test_done "$testroot" "$ret"
905 test_rebase_no_commits_to_rebase() {
906 local testroot=`test_init rebase_no_commits_to_rebase`
908 got checkout $testroot/repo $testroot/wt > /dev/null
909 ret=$?
910 if [ $ret -ne 0 ]; then
911 test_done "$testroot" "$ret"
912 return 1
913 fi
915 (cd $testroot/wt && got branch -n newbranch)
917 echo "modified alpha on master" > $testroot/wt/alpha
918 (cd $testroot/wt && got commit -m 'test rebase_no_commits_to_rebase' \
919 > /dev/null)
920 (cd $testroot/wt && got update > /dev/null)
922 (cd $testroot/wt && got rebase newbranch > $testroot/stdout \
923 2> $testroot/stderr)
925 echo "got: no commits to rebase" > $testroot/stderr.expected
926 cmp -s $testroot/stderr.expected $testroot/stderr
927 ret=$?
928 if [ $ret -ne 0 ]; then
929 diff -u $testroot/stderr.expected $testroot/stderr
930 test_done "$testroot" "$ret"
931 return 1
932 fi
934 echo -n > $testroot/stdout.expected
935 cmp -s $testroot/stdout.expected $testroot/stdout
936 ret=$?
937 if [ $ret -ne 0 ]; then
938 diff -u $testroot/stdout.expected $testroot/stdout
939 test_done "$testroot" "$ret"
940 return 1
941 fi
943 (cd $testroot/wt && got update > $testroot/stdout)
944 echo "Already up-to-date" > $testroot/stdout.expected
945 cmp -s $testroot/stdout.expected $testroot/stdout
946 ret=$?
947 if [ $ret -ne 0 ]; then
948 diff -u $testroot/stdout.expected $testroot/stdout
949 fi
950 test_done "$testroot" "$ret"
953 test_rebase_forward() {
954 local testroot=`test_init rebase_forward`
955 local commit0=`git_show_head $testroot/repo`
957 got checkout $testroot/repo $testroot/wt > /dev/null
958 ret=$?
959 if [ $ret -ne 0 ]; then
960 test_done "$testroot" "$ret"
961 return 1
962 fi
964 echo "change alpha 1" > $testroot/wt/alpha
965 (cd $testroot/wt && got commit -m 'test rebase_forward' \
966 > /dev/null)
967 local commit1=`git_show_head $testroot/repo`
969 echo "change alpha 2" > $testroot/wt/alpha
970 (cd $testroot/wt && got commit -m 'test rebase_forward' \
971 > /dev/null)
972 local commit2=`git_show_head $testroot/repo`
974 # Simulate a situation where fast-forward is required.
975 # We want to fast-forward master to origin/master:
976 # commit 3907e11dceaae2ca7f8db79c2af31794673945ad (origin/master)
977 # commit ffcffcd102cf1af6572fbdbb4cf07a0f1fd2d840 (master)
978 # commit 87a6a8a2263a15b61c016ff1720b24741d455eb5
979 (cd $testroot/repo && got ref -d master >/dev/null)
980 (cd $testroot/repo && got ref -c $commit1 refs/heads/master)
981 (cd $testroot/repo && got ref -c $commit2 refs/remotes/origin/master)
983 (cd $testroot/wt && got up -b origin/master > /dev/null)
985 (cd $testroot/wt && got rebase master \
986 > $testroot/stdout 2> $testroot/stderr)
988 echo "Forwarding refs/heads/master to commit $commit2" \
989 > $testroot/stdout.expected
990 echo "Switching work tree to refs/heads/master" \
991 >> $testroot/stdout.expected
992 cmp -s $testroot/stdout.expected $testroot/stdout
993 ret=$?
994 if [ $ret -ne 0 ]; then
995 diff -u $testroot/stdout.expected $testroot/stdout
996 test_done "$testroot" "$ret"
997 return 1
998 fi
1000 # Ensure that rebase operation was completed correctly
1001 (cd $testroot/wt && got rebase -a \
1002 > $testroot/stdout 2> $testroot/stderr)
1003 echo -n "" > $testroot/stdout.expected
1004 cmp -s $testroot/stdout.expected $testroot/stdout
1005 ret=$?
1006 if [ $ret -ne 0 ]; then
1007 diff -u $testroot/stdout.expected $testroot/stdout
1008 test_done "$testroot" "$ret"
1009 return 1
1011 echo "got: rebase operation not in progress" > $testroot/stderr.expected
1012 cmp -s $testroot/stderr.expected $testroot/stderr
1013 ret=$?
1014 if [ $ret -ne 0 ]; then
1015 diff -u $testroot/stderr.expected $testroot/stderr
1016 test_done "$testroot" "$ret"
1017 return 1
1020 (cd $testroot/wt && got branch -n > $testroot/stdout)
1021 echo "master" > $testroot/stdout.expected
1022 cmp -s $testroot/stdout.expected $testroot/stdout
1023 ret=$?
1024 if [ $ret -ne 0 ]; then
1025 diff -u $testroot/stdout.expected $testroot/stdout
1026 test_done "$testroot" "$ret"
1027 return 1
1030 (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
1031 echo "commit $commit2 (master, origin/master)" > $testroot/stdout.expected
1032 echo "commit $commit1" >> $testroot/stdout.expected
1033 echo "commit $commit0" >> $testroot/stdout.expected
1034 cmp -s $testroot/stdout.expected $testroot/stdout
1035 ret=$?
1036 if [ $ret -ne 0 ]; then
1037 diff -u $testroot/stdout.expected $testroot/stdout
1038 test_done "$testroot" "$ret"
1039 return 1
1042 # Forward-only rebase operations should not be backed up
1043 (cd $testroot/repo && got rebase -l > $testroot/stdout)
1044 echo -n > $testroot/stdout.expected
1045 cmp -s $testroot/stdout.expected $testroot/stdout
1046 ret=$?
1047 if [ $ret -ne 0 ]; then
1048 diff -u $testroot/stdout.expected $testroot/stdout
1050 test_done "$testroot" "$ret"
1053 test_rebase_forward_path_prefix() {
1054 local testroot=`test_init rebase_forward_path_prefix`
1055 local commit0=`git_show_head $testroot/repo`
1057 got checkout $testroot/repo $testroot/wt-full > /dev/null
1058 ret=$?
1059 if [ $ret -ne 0 ]; then
1060 test_done "$testroot" "$ret"
1061 return 1
1064 echo "change alpha 1" > $testroot/wt-full/alpha
1065 (cd $testroot/wt-full && got commit -m 'test rebase_forward' \
1066 > /dev/null)
1067 local commit1=`git_show_head $testroot/repo`
1069 echo "change alpha 2" > $testroot/wt-full/alpha
1070 (cd $testroot/wt-full && got commit -m 'test rebase_forward' \
1071 > /dev/null)
1072 local commit2=`git_show_head $testroot/repo`
1074 # Simulate a situation where fast-forward is required.
1075 # We want to fast-forward master to origin/master:
1076 # commit 3907e11dceaae2ca7f8db79c2af31794673945ad (origin/master)
1077 # commit ffcffcd102cf1af6572fbdbb4cf07a0f1fd2d840 (master)
1078 # commit 87a6a8a2263a15b61c016ff1720b24741d455eb5
1079 (cd $testroot/repo && got ref -d master >/dev/null)
1080 (cd $testroot/repo && got ref -c $commit1 refs/heads/master)
1081 (cd $testroot/repo && got ref -c $commit2 refs/remotes/origin/master)
1083 # Work tree which uses a path-prefix and will be used for rebasing
1084 got checkout -p epsilon -b origin/master $testroot/repo $testroot/wt \
1085 > /dev/null
1086 ret=$?
1087 if [ $ret -ne 0 ]; then
1088 test_done "$testroot" "$ret"
1089 return 1
1092 (cd $testroot/wt && got rebase master \
1093 > $testroot/stdout 2> $testroot/stderr)
1095 echo "Forwarding refs/heads/master to commit $commit2" \
1096 > $testroot/stdout.expected
1097 echo "Switching work tree to refs/heads/master" \
1098 >> $testroot/stdout.expected
1099 cmp -s $testroot/stdout.expected $testroot/stdout
1100 ret=$?
1101 if [ $ret -ne 0 ]; then
1102 diff -u $testroot/stdout.expected $testroot/stdout
1103 test_done "$testroot" "$ret"
1104 return 1
1107 # Ensure that rebase operation was completed correctly
1108 (cd $testroot/wt && got rebase -a \
1109 > $testroot/stdout 2> $testroot/stderr)
1110 echo -n "" > $testroot/stdout.expected
1111 cmp -s $testroot/stdout.expected $testroot/stdout
1112 ret=$?
1113 if [ $ret -ne 0 ]; then
1114 diff -u $testroot/stdout.expected $testroot/stdout
1115 test_done "$testroot" "$ret"
1116 return 1
1118 echo "got: rebase operation not in progress" > $testroot/stderr.expected
1119 cmp -s $testroot/stderr.expected $testroot/stderr
1120 ret=$?
1121 if [ $ret -ne 0 ]; then
1122 diff -u $testroot/stderr.expected $testroot/stderr
1123 test_done "$testroot" "$ret"
1124 return 1
1127 (cd $testroot/wt && got branch -n > $testroot/stdout)
1128 echo "master" > $testroot/stdout.expected
1129 cmp -s $testroot/stdout.expected $testroot/stdout
1130 ret=$?
1131 if [ $ret -ne 0 ]; then
1132 diff -u $testroot/stdout.expected $testroot/stdout
1133 test_done "$testroot" "$ret"
1134 return 1
1137 (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
1138 echo "commit $commit2 (master, origin/master)" > $testroot/stdout.expected
1139 echo "commit $commit1" >> $testroot/stdout.expected
1140 echo "commit $commit0" >> $testroot/stdout.expected
1141 cmp -s $testroot/stdout.expected $testroot/stdout
1142 ret=$?
1143 if [ $ret -ne 0 ]; then
1144 diff -u $testroot/stdout.expected $testroot/stdout
1145 test_done "$testroot" "$ret"
1146 return 1
1149 # Forward-only rebase operations should not be backed up
1150 (cd $testroot/repo && got rebase -l > $testroot/stdout)
1151 echo -n > $testroot/stdout.expected
1152 cmp -s $testroot/stdout.expected $testroot/stdout
1153 ret=$?
1154 if [ $ret -ne 0 ]; then
1155 diff -u $testroot/stdout.expected $testroot/stdout
1157 test_done "$testroot" "$ret"
1160 test_rebase_out_of_date() {
1161 local testroot=`test_init rebase_out_of_date`
1162 local initial_commit=`git_show_head $testroot/repo`
1164 (cd $testroot/repo && git checkout -q -b newbranch)
1165 echo "modified delta on branch" > $testroot/repo/gamma/delta
1166 git_commit $testroot/repo -m "committing to delta on newbranch"
1168 echo "modified alpha on branch" > $testroot/repo/alpha
1169 (cd $testroot/repo && git rm -q beta)
1170 echo "new file on branch" > $testroot/repo/epsilon/new
1171 (cd $testroot/repo && git add epsilon/new)
1172 git_commit $testroot/repo -m "committing more changes on newbranch"
1174 local orig_commit1=`git_show_parent_commit $testroot/repo`
1175 local orig_commit2=`git_show_head $testroot/repo`
1177 (cd $testroot/repo && git checkout -q master)
1178 echo "modified zeta on master" > $testroot/repo/epsilon/zeta
1179 git_commit $testroot/repo -m "committing to zeta on master"
1180 local master_commit1=`git_show_head $testroot/repo`
1182 (cd $testroot/repo && git checkout -q master)
1183 echo "modified beta on master" > $testroot/repo/beta
1184 git_commit $testroot/repo -m "committing to beta on master"
1185 local master_commit2=`git_show_head $testroot/repo`
1187 got checkout -c $master_commit1 $testroot/repo $testroot/wt \
1188 > /dev/null
1189 ret=$?
1190 if [ $ret -ne 0 ]; then
1191 test_done "$testroot" "$ret"
1192 return 1
1195 (cd $testroot/wt && got rebase newbranch > $testroot/stdout \
1196 2> $testroot/stderr)
1198 echo -n > $testroot/stdout.expected
1199 cmp -s $testroot/stdout.expected $testroot/stdout
1200 ret=$?
1201 if [ $ret -ne 0 ]; then
1202 diff -u $testroot/stdout.expected $testroot/stdout
1203 test_done "$testroot" "$ret"
1204 return 1
1207 echo -n "got: work tree must be updated before it can be " \
1208 > $testroot/stderr.expected
1209 echo "used to rebase a branch" >> $testroot/stderr.expected
1210 cmp -s $testroot/stderr.expected $testroot/stderr
1211 ret=$?
1212 if [ $ret -ne 0 ]; then
1213 diff -u $testroot/stderr.expected $testroot/stderr
1214 test_done "$testroot" "$ret"
1215 return 1
1218 (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
1219 echo "commit $master_commit2 (master)" > $testroot/stdout.expected
1220 echo "commit $master_commit1" >> $testroot/stdout.expected
1221 echo "commit $initial_commit" >> $testroot/stdout.expected
1222 cmp -s $testroot/stdout.expected $testroot/stdout
1223 ret=$?
1224 if [ $ret -ne 0 ]; then
1225 diff -u $testroot/stdout.expected $testroot/stdout
1227 test_done "$testroot" "$ret"
1230 test_rebase_trims_empty_dir() {
1231 local testroot=`test_init rebase_trims_empty_dir`
1233 (cd $testroot/repo && git checkout -q -b newbranch)
1234 echo "modified delta on branch" > $testroot/repo/gamma/delta
1235 git_commit $testroot/repo -m "committing to delta on newbranch"
1237 (cd $testroot/repo && git rm -q epsilon/zeta)
1238 git_commit $testroot/repo -m "removing zeta on newbranch"
1240 local orig_commit1=`git_show_parent_commit $testroot/repo`
1241 local orig_commit2=`git_show_head $testroot/repo`
1243 (cd $testroot/repo && git checkout -q master)
1244 echo "modified alpha on master" > $testroot/repo/alpha
1245 git_commit $testroot/repo -m "committing to alpha on master"
1246 local master_commit=`git_show_head $testroot/repo`
1248 got checkout $testroot/repo $testroot/wt > /dev/null
1249 ret=$?
1250 if [ $ret -ne 0 ]; then
1251 test_done "$testroot" "$ret"
1252 return 1
1255 (cd $testroot/wt && got rebase newbranch > $testroot/stdout)
1257 (cd $testroot/repo && git checkout -q newbranch)
1258 local new_commit1=`git_show_parent_commit $testroot/repo`
1259 local new_commit2=`git_show_head $testroot/repo`
1261 local short_orig_commit1=`trim_obj_id 28 $orig_commit1`
1262 local short_orig_commit2=`trim_obj_id 28 $orig_commit2`
1263 local short_new_commit1=`trim_obj_id 28 $new_commit1`
1264 local short_new_commit2=`trim_obj_id 28 $new_commit2`
1266 echo "G gamma/delta" >> $testroot/stdout.expected
1267 echo -n "$short_orig_commit1 -> $short_new_commit1" \
1268 >> $testroot/stdout.expected
1269 echo ": committing to delta on newbranch" >> $testroot/stdout.expected
1270 echo "D epsilon/zeta" >> $testroot/stdout.expected
1271 echo -n "$short_orig_commit2 -> $short_new_commit2" \
1272 >> $testroot/stdout.expected
1273 echo ": removing zeta on newbranch" \
1274 >> $testroot/stdout.expected
1275 echo "Switching work tree to refs/heads/newbranch" \
1276 >> $testroot/stdout.expected
1278 cmp -s $testroot/stdout.expected $testroot/stdout
1279 ret=$?
1280 if [ $ret -ne 0 ]; then
1281 diff -u $testroot/stdout.expected $testroot/stdout
1282 test_done "$testroot" "$ret"
1283 return 1
1286 echo "modified delta on branch" > $testroot/content.expected
1287 cat $testroot/wt/gamma/delta > $testroot/content
1288 cmp -s $testroot/content.expected $testroot/content
1289 ret=$?
1290 if [ $ret -ne 0 ]; then
1291 diff -u $testroot/content.expected $testroot/content
1292 test_done "$testroot" "$ret"
1293 return 1
1296 echo "modified alpha on master" > $testroot/content.expected
1297 cat $testroot/wt/alpha > $testroot/content
1298 cmp -s $testroot/content.expected $testroot/content
1299 ret=$?
1300 if [ $ret -ne 0 ]; then
1301 diff -u $testroot/content.expected $testroot/content
1302 test_done "$testroot" "$ret"
1303 return 1
1306 if [ -e $testroot/wt/epsilon ]; then
1307 echo "parent of removed zeta still exists on disk" >&2
1308 test_done "$testroot" "1"
1309 return 1
1312 (cd $testroot/wt && got status > $testroot/stdout)
1314 echo -n > $testroot/stdout.expected
1315 cmp -s $testroot/stdout.expected $testroot/stdout
1316 ret=$?
1317 if [ $ret -ne 0 ]; then
1318 diff -u $testroot/stdout.expected $testroot/stdout
1319 test_done "$testroot" "$ret"
1320 return 1
1323 (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
1324 echo "commit $new_commit2 (newbranch)" > $testroot/stdout.expected
1325 echo "commit $new_commit1" >> $testroot/stdout.expected
1326 echo "commit $master_commit (master)" >> $testroot/stdout.expected
1327 cmp -s $testroot/stdout.expected $testroot/stdout
1328 ret=$?
1329 if [ $ret -ne 0 ]; then
1330 diff -u $testroot/stdout.expected $testroot/stdout
1332 test_done "$testroot" "$ret"
1335 test_rebase_delete_missing_file() {
1336 local testroot=`test_init rebase_delete_missing_file`
1338 mkdir -p $testroot/repo/d/f/g
1339 echo "new file" > $testroot/repo/d/f/g/new
1340 (cd $testroot/repo && git add d/f/g/new)
1341 git_commit $testroot/repo -m "adding a subdir"
1342 local commit0=`git_show_head $testroot/repo`
1344 got br -r $testroot/repo -c master newbranch
1346 got checkout -b newbranch $testroot/repo $testroot/wt > /dev/null
1348 echo "modified delta on branch" > $testroot/wt/gamma/delta
1349 (cd $testroot/wt && got commit \
1350 -m "committing to delta on newbranch" > /dev/null)
1352 (cd $testroot/wt && got rm beta d/f/g/new > /dev/null)
1353 (cd $testroot/wt && got commit \
1354 -m "removing beta and d/f/g/new on newbranch" > /dev/null)
1356 (cd $testroot/repo && git checkout -q newbranch)
1357 local orig_commit1=`git_show_parent_commit $testroot/repo`
1358 local orig_commit2=`git_show_head $testroot/repo`
1360 local short_orig_commit1=`trim_obj_id 28 $orig_commit1`
1361 local short_orig_commit2=`trim_obj_id 28 $orig_commit2`
1363 (cd $testroot/wt && got update -b master > /dev/null)
1364 (cd $testroot/wt && got rm beta d/f/g/new > /dev/null)
1365 (cd $testroot/wt && got commit \
1366 -m "removing beta and d/f/g/new on master" > /dev/null)
1368 (cd $testroot/repo && git checkout -q master)
1369 local master_commit=`git_show_head $testroot/repo`
1371 (cd $testroot/wt && got update -b master > /dev/null)
1372 (cd $testroot/wt && got rebase newbranch > $testroot/stdout \
1373 2> $testroot/stderr)
1374 ret=$?
1375 if [ $ret -eq 0 ]; then
1376 echo "rebase succeeded unexpectedly" >&2
1377 test_done "$testroot" "1"
1378 return 1
1381 local new_commit1=$(cd $testroot/wt && got info | \
1382 grep '^work tree base commit: ' | cut -d: -f2 | tr -d ' ')
1384 local short_orig_commit2=`trim_obj_id 28 $orig_commit2`
1385 local short_new_commit1=`trim_obj_id 28 $new_commit1`
1387 echo "G gamma/delta" >> $testroot/stdout.expected
1388 echo -n "$short_orig_commit1 -> $short_new_commit1" \
1389 >> $testroot/stdout.expected
1390 echo ": committing to delta on newbranch" >> $testroot/stdout.expected
1391 echo "! beta" >> $testroot/stdout.expected
1392 echo "! d/f/g/new" >> $testroot/stdout.expected
1393 echo -n "Files which had incoming changes but could not be found " \
1394 >> $testroot/stdout.expected
1395 echo "in the work tree: 2" >> $testroot/stdout.expected
1396 cmp -s $testroot/stdout.expected $testroot/stdout
1397 ret=$?
1398 if [ $ret -ne 0 ]; then
1399 diff -u $testroot/stdout.expected $testroot/stdout
1400 test_done "$testroot" "$ret"
1401 return 1
1404 echo -n "got: changes destined for some files were not yet merged " \
1405 > $testroot/stderr.expected
1406 echo -n "and should be merged manually if required before the " \
1407 >> $testroot/stderr.expected
1408 echo "rebase operation is continued" >> $testroot/stderr.expected
1409 cmp -s $testroot/stderr.expected $testroot/stderr
1410 ret=$?
1411 if [ $ret -ne 0 ]; then
1412 diff -u $testroot/stderr.expected $testroot/stderr
1413 test_done "$testroot" "$ret"
1414 return 1
1417 # ignore the missing changes and continue
1418 (cd $testroot/wt && got rebase -c > $testroot/stdout)
1419 ret=$?
1420 if [ $ret -ne 0 ]; then
1421 echo "rebase failed unexpectedly" >&2
1422 test_done "$testroot" "1"
1423 return 1
1425 echo -n "$short_orig_commit2 -> no-op change" \
1426 > $testroot/stdout.expected
1427 echo ": removing beta and d/f/g/new on newbranch" \
1428 >> $testroot/stdout.expected
1429 echo "Switching work tree to refs/heads/newbranch" \
1430 >> $testroot/stdout.expected
1432 cmp -s $testroot/stdout.expected $testroot/stdout
1433 ret=$?
1434 if [ $ret -ne 0 ]; then
1435 diff -u $testroot/stdout.expected $testroot/stdout
1436 test_done "$testroot" "$ret"
1437 return 1
1440 echo "modified delta on branch" > $testroot/content.expected
1441 cat $testroot/wt/gamma/delta > $testroot/content
1442 cmp -s $testroot/content.expected $testroot/content
1443 ret=$?
1444 if [ $ret -ne 0 ]; then
1445 diff -u $testroot/content.expected $testroot/content
1446 test_done "$testroot" "$ret"
1447 return 1
1450 if [ -e $testroot/wt/beta ]; then
1451 echo "removed file beta still exists on disk" >&2
1452 test_done "$testroot" "1"
1453 return 1
1456 (cd $testroot/wt && got status > $testroot/stdout)
1458 echo -n > $testroot/stdout.expected
1459 cmp -s $testroot/stdout.expected $testroot/stdout
1460 ret=$?
1461 if [ $ret -ne 0 ]; then
1462 diff -u $testroot/stdout.expected $testroot/stdout
1463 test_done "$testroot" "$ret"
1464 return 1
1467 (cd $testroot/repo && git checkout -q newbranch)
1468 local new_commit1=`git_show_head $testroot/repo`
1469 local short_new_commit1=`trim_obj_id 28 $new_commit1`
1471 (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
1472 echo "commit $new_commit1 (newbranch)" > $testroot/stdout.expected
1473 echo "commit $master_commit (master)" >> $testroot/stdout.expected
1474 echo "commit $commit0" >> $testroot/stdout.expected
1475 cmp -s $testroot/stdout.expected $testroot/stdout
1476 ret=$?
1477 if [ $ret -ne 0 ]; then
1478 diff -u $testroot/stdout.expected $testroot/stdout
1480 test_done "$testroot" "$ret"
1483 test_rebase_rm_add_rm_file() {
1484 local testroot=`test_init rebase_rm_add_rm_file`
1486 (cd $testroot/repo && git checkout -q -b newbranch)
1487 (cd $testroot/repo && git rm -q beta)
1488 git_commit $testroot/repo -m "removing beta from newbranch"
1489 local orig_commit1=`git_show_head $testroot/repo`
1491 echo 'restored beta' > $testroot/repo/beta
1492 (cd $testroot/repo && git add beta)
1493 git_commit $testroot/repo -m "restoring beta on newbranch"
1494 local orig_commit2=`git_show_head $testroot/repo`
1496 (cd $testroot/repo && git rm -q beta)
1497 git_commit $testroot/repo -m "removing beta from newbranch again"
1498 local orig_commit3=`git_show_head $testroot/repo`
1500 (cd $testroot/repo && git checkout -q master)
1501 echo "modified zeta on master" > $testroot/repo/epsilon/zeta
1502 git_commit $testroot/repo -m "committing to zeta on master"
1503 local master_commit=`git_show_head $testroot/repo`
1505 got checkout $testroot/repo $testroot/wt > /dev/null
1506 ret=$?
1507 if [ $ret -ne 0 ]; then
1508 test_done "$testroot" "$ret"
1509 return 1
1512 (cd $testroot/wt && got rebase newbranch > $testroot/stdout)
1514 # this would error out with 'got: file index is corrupt'
1515 (cd $testroot/wt && got status > /dev/null)
1516 ret=$?
1517 if [ $ret -ne 0 ]; then
1518 echo "got status command failed unexpectedly" >&2
1519 test_done "$testroot" "$ret"
1520 return 1
1523 (cd $testroot/repo && git checkout -q newbranch)
1524 local new_commit3=`git_show_head $testroot/repo`
1525 local new_commit2=`git_show_parent_commit $testroot/repo`
1526 local new_commit1=`git_show_parent_commit $testroot/repo $new_commit2`
1528 (cd $testroot/repo && git checkout -q newbranch)
1530 local short_orig_commit1=`trim_obj_id 28 $orig_commit1`
1531 local short_orig_commit2=`trim_obj_id 28 $orig_commit2`
1532 local short_orig_commit3=`trim_obj_id 28 $orig_commit3`
1533 local short_new_commit1=`trim_obj_id 28 $new_commit1`
1534 local short_new_commit2=`trim_obj_id 28 $new_commit2`
1535 local short_new_commit3=`trim_obj_id 28 $new_commit3`
1537 echo "D beta" > $testroot/stdout.expected
1538 echo -n "$short_orig_commit1 -> $short_new_commit1" \
1539 >> $testroot/stdout.expected
1540 echo ": removing beta from newbranch" >> $testroot/stdout.expected
1541 echo "A beta" >> $testroot/stdout.expected
1542 echo -n "$short_orig_commit2 -> $short_new_commit2" \
1543 >> $testroot/stdout.expected
1544 echo ": restoring beta on newbranch" >> $testroot/stdout.expected
1545 echo "D beta" >> $testroot/stdout.expected
1546 echo -n "$short_orig_commit3 -> $short_new_commit3" \
1547 >> $testroot/stdout.expected
1548 echo ": removing beta from newbranch again" >> $testroot/stdout.expected
1549 echo "Switching work tree to refs/heads/newbranch" \
1550 >> $testroot/stdout.expected
1552 cmp -s $testroot/stdout.expected $testroot/stdout
1553 ret=$?
1554 if [ $ret -ne 0 ]; then
1555 diff -u $testroot/stdout.expected $testroot/stdout
1556 test_done "$testroot" "$ret"
1557 return 1
1560 (cd $testroot/wt && got status > $testroot/stdout)
1561 ret=$?
1562 if [ $ret -ne 0 ]; then
1563 echo "got status command failed unexpectedly" >&2
1564 test_done "$testroot" "$ret"
1565 return 1
1568 echo -n > $testroot/stdout.expected
1569 cmp -s $testroot/stdout.expected $testroot/stdout
1570 ret=$?
1571 if [ $ret -ne 0 ]; then
1572 diff -u $testroot/stdout.expected $testroot/stdout
1573 test_done "$testroot" "$ret"
1574 return 1
1577 (cd $testroot/wt && got log -l4 | grep ^commit > $testroot/stdout)
1578 echo "commit $new_commit3 (newbranch)" > $testroot/stdout.expected
1579 echo "commit $new_commit2" >> $testroot/stdout.expected
1580 echo "commit $new_commit1" >> $testroot/stdout.expected
1581 echo "commit $master_commit (master)" >> $testroot/stdout.expected
1582 cmp -s $testroot/stdout.expected $testroot/stdout
1583 ret=$?
1584 if [ $ret -ne 0 ]; then
1585 diff -u $testroot/stdout.expected $testroot/stdout
1587 test_done "$testroot" "$ret"
1590 test_rebase_resets_committer() {
1591 local testroot=`test_init rebase_resets_committer`
1592 local commit0=`git_show_head $testroot/repo`
1593 local commit0_author_time=`git_show_author_time $testroot/repo`
1594 local committer="Flan Luck <flan_luck@openbsd.org>"
1596 (cd $testroot/repo && git checkout -q -b newbranch)
1597 echo "modified delta on branch" > $testroot/repo/gamma/delta
1598 git_commit $testroot/repo -m "committing to delta on newbranch"
1600 echo "modified alpha on branch" > $testroot/repo/alpha
1601 git_commit $testroot/repo -m "committing more changes on newbranch"
1603 local orig_commit1=`git_show_parent_commit $testroot/repo`
1604 local orig_commit2=`git_show_head $testroot/repo`
1605 local orig_author_time2=`git_show_author_time $testroot/repo`
1607 (cd $testroot/repo && git checkout -q master)
1608 echo "modified zeta on master" > $testroot/repo/epsilon/zeta
1609 git_commit $testroot/repo -m "committing to zeta on master"
1610 local master_commit=`git_show_head $testroot/repo`
1612 got checkout $testroot/repo $testroot/wt > /dev/null
1613 ret=$?
1614 if [ $ret -ne 0 ]; then
1615 test_done "$testroot" "$ret"
1616 return 1
1619 (cd $testroot/wt && env GOT_AUTHOR="$committer" \
1620 got rebase newbranch > $testroot/stdout)
1622 (cd $testroot/repo && git checkout -q newbranch)
1623 local new_commit1=`git_show_parent_commit $testroot/repo`
1624 local new_commit2=`git_show_head $testroot/repo`
1625 local new_author_time2=`git_show_author_time $testroot/repo`
1627 local short_orig_commit1=`trim_obj_id 28 $orig_commit1`
1628 local short_orig_commit2=`trim_obj_id 28 $orig_commit2`
1629 local short_new_commit1=`trim_obj_id 28 $new_commit1`
1630 local short_new_commit2=`trim_obj_id 28 $new_commit2`
1632 echo "G gamma/delta" >> $testroot/stdout.expected
1633 echo -n "$short_orig_commit1 -> $short_new_commit1" \
1634 >> $testroot/stdout.expected
1635 echo ": committing to delta on newbranch" >> $testroot/stdout.expected
1636 echo "G alpha" >> $testroot/stdout.expected
1637 echo -n "$short_orig_commit2 -> $short_new_commit2" \
1638 >> $testroot/stdout.expected
1639 echo ": committing more changes on newbranch" \
1640 >> $testroot/stdout.expected
1641 echo "Switching work tree to refs/heads/newbranch" \
1642 >> $testroot/stdout.expected
1644 cmp -s $testroot/stdout.expected $testroot/stdout
1645 ret=$?
1646 if [ $ret -ne 0 ]; then
1647 diff -u $testroot/stdout.expected $testroot/stdout
1648 test_done "$testroot" "$ret"
1649 return 1
1652 # Original commit only had one author
1653 (cd $testroot/repo && got log -l1 -c $orig_commit2 | \
1654 egrep '^(from|via):' > $testroot/stdout)
1655 echo "from: $GOT_AUTHOR" > $testroot/stdout.expected
1656 cmp -s $testroot/stdout.expected $testroot/stdout
1657 ret=$?
1658 if [ $ret -ne 0 ]; then
1659 diff -u $testroot/stdout.expected $testroot/stdout
1660 test_done "$testroot" "$ret"
1661 return 1
1664 # Rebased commit should have new committer name added
1665 (cd $testroot/repo && got log -l1 -c $new_commit2 | \
1666 egrep '^(from|via):' > $testroot/stdout)
1667 echo "from: $GOT_AUTHOR" > $testroot/stdout.expected
1668 echo "via: $committer" >> $testroot/stdout.expected
1670 cmp -s $testroot/stdout.expected $testroot/stdout
1671 ret=$?
1672 if [ $ret -ne 0 ]; then
1673 diff -u $testroot/stdout.expected $testroot/stdout
1675 test_done "$testroot" "$ret"
1678 test_rebase_no_author_info() {
1679 local testroot=`test_init rebase_no_author_info`
1680 local commit0=`git_show_head $testroot/repo`
1681 local commit0_author_time=`git_show_author_time $testroot/repo`
1682 local committer="$GOT_AUTHOR"
1684 (cd $testroot/repo && git checkout -q -b newbranch)
1685 echo "modified delta on branch" > $testroot/repo/gamma/delta
1686 git_commit $testroot/repo -m "committing to delta on newbranch"
1688 echo "modified alpha on branch" > $testroot/repo/alpha
1689 git_commit $testroot/repo -m "committing more changes on newbranch"
1691 local orig_commit1=`git_show_parent_commit $testroot/repo`
1692 local orig_commit2=`git_show_head $testroot/repo`
1693 local orig_author_time2=`git_show_author_time $testroot/repo`
1695 (cd $testroot/repo && git checkout -q master)
1696 echo "modified zeta on master" > $testroot/repo/epsilon/zeta
1697 git_commit $testroot/repo -m "committing to zeta on master"
1698 local master_commit=`git_show_head $testroot/repo`
1700 got checkout $testroot/repo $testroot/wt > /dev/null
1701 ret=$?
1702 if [ $ret -ne 0 ]; then
1703 test_done "$testroot" "$ret"
1704 return 1
1707 # unset in a subshell to avoid affecting our environment
1708 (unset GOT_AUTHOR && cd $testroot/wt && \
1709 got rebase newbranch > $testroot/stdout)
1711 (cd $testroot/repo && git checkout -q newbranch)
1712 local new_commit1=`git_show_parent_commit $testroot/repo`
1713 local new_commit2=`git_show_head $testroot/repo`
1714 local new_author_time2=`git_show_author_time $testroot/repo`
1716 local short_orig_commit1=`trim_obj_id 28 $orig_commit1`
1717 local short_orig_commit2=`trim_obj_id 28 $orig_commit2`
1718 local short_new_commit1=`trim_obj_id 28 $new_commit1`
1719 local short_new_commit2=`trim_obj_id 28 $new_commit2`
1721 echo "G gamma/delta" >> $testroot/stdout.expected
1722 echo -n "$short_orig_commit1 -> $short_new_commit1" \
1723 >> $testroot/stdout.expected
1724 echo ": committing to delta on newbranch" >> $testroot/stdout.expected
1725 echo "G alpha" >> $testroot/stdout.expected
1726 echo -n "$short_orig_commit2 -> $short_new_commit2" \
1727 >> $testroot/stdout.expected
1728 echo ": committing more changes on newbranch" \
1729 >> $testroot/stdout.expected
1730 echo "Switching work tree to refs/heads/newbranch" \
1731 >> $testroot/stdout.expected
1733 cmp -s $testroot/stdout.expected $testroot/stdout
1734 ret=$?
1735 if [ $ret -ne 0 ]; then
1736 diff -u $testroot/stdout.expected $testroot/stdout
1737 test_done "$testroot" "$ret"
1738 return 1
1741 # Original commit only had one author
1742 (cd $testroot/repo && got log -l1 -c $orig_commit2 | \
1743 egrep '^(from|via):' > $testroot/stdout)
1744 echo "from: $committer" > $testroot/stdout.expected
1745 cmp -s $testroot/stdout.expected $testroot/stdout
1746 ret=$?
1747 if [ $ret -ne 0 ]; then
1748 diff -u $testroot/stdout.expected $testroot/stdout
1749 test_done "$testroot" "$ret"
1750 return 1
1753 # Author info of rebased commit should match the original
1754 (cd $testroot/repo && got log -l1 -c $new_commit2 | \
1755 egrep '^(from|via):' > $testroot/stdout)
1756 echo "from: $committer" > $testroot/stdout.expected
1758 cmp -s $testroot/stdout.expected $testroot/stdout
1759 ret=$?
1760 if [ $ret -ne 0 ]; then
1761 diff -u $testroot/stdout.expected $testroot/stdout
1763 test_done "$testroot" "$ret"
1766 test_rebase_nonbranch() {
1767 local testroot=`test_init rebase_nonbranch`
1769 got ref -r $testroot/repo -c refs/heads/master \
1770 refs/remotes/origin/master >/dev/null
1772 got checkout -b master $testroot/repo $testroot/wt >/dev/null
1774 (cd $testroot/wt && got rebase origin/master > $testroot/stdout \
1775 2> $testroot/stderr)
1776 ret=$?
1777 if [ $ret -eq 0 ]; then
1778 echo "rebase succeeded unexpectedly" >&2
1779 test_done "$testroot" "1"
1780 return 1
1782 echo -n "got: will not rebase a branch which lives outside the " \
1783 > $testroot/stderr.expected
1784 echo '"refs/heads/" reference namespace' >> $testroot/stderr.expected
1785 cmp -s $testroot/stderr.expected $testroot/stderr
1786 ret=$?
1787 if [ $ret -ne 0 ]; then
1788 diff -u $testroot/stderr.expected $testroot/stderr
1790 test_done "$testroot" "$ret"
1793 test_rebase_umask() {
1794 local testroot=`test_init rebase_umask`
1795 local commit0=`git_show_head "$testroot/repo"`
1797 got checkout "$testroot/repo" "$testroot/wt" >/dev/null
1798 (cd "$testroot/wt" && got branch newbranch) >/dev/null
1800 echo "modified alpha on branch" >$testroot/wt/alpha
1801 (cd "$testroot/wt" && got commit -m 'modified alpha on newbranch') \
1802 >/dev/null
1804 (cd "$testroot/wt" && got update -b master) >/dev/null
1805 ret=$?
1806 if [ $ret -ne 0 ]; then
1807 echo "got update failed!" >&2
1808 test_done "$testroot" $ret
1809 return 1
1812 echo "modified beta on master" >$testroot/wt/beta
1813 (cd "$testroot/wt" && got commit -m 'modified beta on master') \
1814 >/dev/null
1815 (cd "$testroot/wt" && got update) >/dev/null
1817 # using a subshell to avoid clobbering global umask
1818 (umask 077 && cd "$testroot/wt" && got rebase newbranch) >/dev/null
1819 ret=$?
1820 if [ $ret -ne 0 ]; then
1821 echo "got rebase failed" >&2
1822 test_done "$testroot" $ret
1823 return 1
1826 ls -l "$testroot/wt/alpha" | grep -q ^-rw-------
1827 if [ $? -ne 0 ]; then
1828 echo "alpha is not 0600 after rebase" >&2
1829 ls -l "$testroot/wt/alpha" >&2
1830 test_done "$testroot" 1
1831 return 1
1834 test_done "$testroot" 0
1837 test_parseargs "$@"
1838 run_test test_rebase_basic
1839 run_test test_rebase_ancestry_check
1840 run_test test_rebase_continue
1841 run_test test_rebase_abort
1842 run_test test_rebase_no_op_change
1843 run_test test_rebase_in_progress
1844 run_test test_rebase_path_prefix
1845 run_test test_rebase_preserves_logmsg
1846 run_test test_rebase_no_commits_to_rebase
1847 run_test test_rebase_forward
1848 run_test test_rebase_forward_path_prefix
1849 run_test test_rebase_out_of_date
1850 run_test test_rebase_trims_empty_dir
1851 run_test test_rebase_delete_missing_file
1852 run_test test_rebase_rm_add_rm_file
1853 run_test test_rebase_resets_committer
1854 run_test test_rebase_no_author_info
1855 run_test test_rebase_nonbranch
1856 run_test test_rebase_umask