3 # Copyright (c) 2021 Stefan Sperling <stsp@openbsd.org>
5 # Permission to use, copy, modify, and distribute this software for any
6 # purpose with or without fee is hereby granted, provided that the above
7 # copyright notice and this permission notice appear in all copies.
9 # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
20 local testroot=`test_init merge_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"
27 local branch_commit0=`git_show_branch_head $testroot/repo newbranch`
29 echo "modified alpha on branch" > $testroot/repo/alpha
30 git_commit $testroot/repo -m "committing to alpha on newbranch"
31 local branch_commit1=`git_show_branch_head $testroot/repo newbranch`
32 (cd $testroot/repo && git rm -q beta)
33 git_commit $testroot/repo -m "removing beta on newbranch"
34 local branch_commit2=`git_show_branch_head $testroot/repo newbranch`
35 echo "new file on branch" > $testroot/repo/epsilon/new
36 (cd $testroot/repo && git add epsilon/new)
37 git_commit $testroot/repo -m "adding new file on newbranch"
38 local branch_commit3=`git_show_branch_head $testroot/repo newbranch`
39 (cd $testroot/repo && ln -s alpha symlink && git add symlink)
40 git_commit $testroot/repo -m "adding symlink on newbranch"
41 local branch_commit4=`git_show_branch_head $testroot/repo newbranch`
42 (cd $testroot/repo && ln -sf .got/bar dotgotbar.link)
43 (cd $testroot/repo && git add dotgotbar.link)
44 git_commit $testroot/repo -m "adding a bad symlink on newbranch"
45 local branch_commit5=`git_show_branch_head $testroot/repo newbranch`
47 got checkout -b master $testroot/repo $testroot/wt > /dev/null
49 if [ $ret -ne 0 ]; then
50 echo "got checkout failed unexpectedly" >&2
51 test_done "$testroot" "$ret"
55 # need a divergant commit on the main branch for 'got merge'
56 (cd $testroot/wt && got merge newbranch \
57 > $testroot/stdout 2> $testroot/stderr)
59 if [ $ret -eq 0 ]; then
60 echo "got merge succeeded unexpectedly" >&2
61 test_done "$testroot" "1"
64 echo -n "got: cannot create a merge commit because " \
65 > $testroot/stderr.expected
66 echo -n "refs/heads/newbranch is based on refs/heads/master; " \
67 >> $testroot/stderr.expected
68 echo -n "refs/heads/newbranch can be integrated with " \
69 >> $testroot/stderr.expected
70 echo "'got integrate' instead" >> $testroot/stderr.expected
71 cmp -s $testroot/stderr.expected $testroot/stderr
73 if [ $ret -ne 0 ]; then
74 diff -u $testroot/stderr.expected $testroot/stderr
75 test_done "$testroot" "$ret"
79 # create the required dirvergant commit
80 (cd $testroot/repo && git checkout -q master)
81 echo "modified zeta on master" > $testroot/repo/epsilon/zeta
82 git_commit $testroot/repo -m "committing to zeta on master"
83 local master_commit=`git_show_head $testroot/repo`
85 # need an up-to-date work tree for 'got merge'
86 (cd $testroot/wt && got merge newbranch \
87 > $testroot/stdout 2> $testroot/stderr)
89 if [ $ret -eq 0 ]; then
90 echo "got merge succeeded unexpectedly" >&2
91 test_done "$testroot" "$ret"
94 echo -n "got: work tree must be updated before it can be used " \
95 > $testroot/stderr.expected
96 echo "to merge a branch" >> $testroot/stderr.expected
97 cmp -s $testroot/stderr.expected $testroot/stderr
99 if [ $ret -ne 0 ]; then
100 diff -u $testroot/stderr.expected $testroot/stderr
101 test_done "$testroot" "$ret"
105 (cd $testroot/wt && got update > /dev/null)
107 if [ $ret -ne 0 ]; then
108 echo "got update failed unexpectedly" >&2
109 test_done "$testroot" "$ret"
113 # must not use a mixed-commit work tree with 'got merge'
114 (cd $testroot/wt && got update -c $commit0 alpha > /dev/null)
116 if [ $ret -ne 0 ]; then
117 echo "got update failed unexpectedly" >&2
118 test_done "$testroot" "$ret"
121 (cd $testroot/wt && got merge newbranch \
122 > $testroot/stdout 2> $testroot/stderr)
124 if [ $ret -eq 0 ]; then
125 echo "got merge succeeded unexpectedly" >&2
126 test_done "$testroot" "$ret"
129 echo -n "got: work tree contains files from multiple base commits; " \
130 > $testroot/stderr.expected
131 echo "the entire work tree must be updated first" \
132 >> $testroot/stderr.expected
133 cmp -s $testroot/stderr.expected $testroot/stderr
135 if [ $ret -ne 0 ]; then
136 diff -u $testroot/stderr.expected $testroot/stderr
137 test_done "$testroot" "$ret"
141 (cd $testroot/wt && got update > /dev/null)
143 if [ $ret -ne 0 ]; then
144 echo "got update failed unexpectedly" >&2
145 test_done "$testroot" "$ret"
149 # must not have staged files with 'got merge'
150 echo "modified file alpha" > $testroot/wt/alpha
151 (cd $testroot/wt && got stage alpha > /dev/null)
153 if [ $ret -ne 0 ]; then
154 echo "got stage failed unexpectedly" >&2
155 test_done "$testroot" "$ret"
158 (cd $testroot/wt && got merge newbranch \
159 > $testroot/stdout 2> $testroot/stderr)
161 if [ $ret -eq 0 ]; then
162 echo "got merge succeeded unexpectedly" >&2
163 test_done "$testroot" "$ret"
166 echo "got: alpha: file is staged" > $testroot/stderr.expected
167 cmp -s $testroot/stderr.expected $testroot/stderr
169 if [ $ret -ne 0 ]; then
170 diff -u $testroot/stderr.expected $testroot/stderr
171 test_done "$testroot" "$ret"
174 (cd $testroot/wt && got unstage alpha > /dev/null)
176 if [ $ret -ne 0 ]; then
177 echo "got unstage failed unexpectedly" >&2
178 test_done "$testroot" "$ret"
182 # must not have local changes with 'got merge'
183 (cd $testroot/wt && got merge newbranch \
184 > $testroot/stdout 2> $testroot/stderr)
186 if [ $ret -eq 0 ]; then
187 echo "got merge succeeded unexpectedly" >&2
188 test_done "$testroot" "$ret"
191 echo -n "got: work tree contains local changes; " \
192 > $testroot/stderr.expected
193 echo "these changes must be committed or reverted first" \
194 >> $testroot/stderr.expected
195 cmp -s $testroot/stderr.expected $testroot/stderr
197 if [ $ret -ne 0 ]; then
198 diff -u $testroot/stderr.expected $testroot/stderr
199 test_done "$testroot" "$ret"
203 (cd $testroot/wt && got revert alpha > /dev/null)
205 if [ $ret -ne 0 ]; then
206 echo "got revert failed unexpectedly" >&2
207 test_done "$testroot" "$ret"
211 (cd $testroot/wt && got merge newbranch > $testroot/stdout)
213 if [ $ret -ne 0 ]; then
214 echo "got merge failed unexpectedly" >&2
215 test_done "$testroot" "$ret"
219 local merge_commit=`git_show_head $testroot/repo`
221 echo "G alpha" >> $testroot/stdout.expected
222 echo "D beta" >> $testroot/stdout.expected
223 echo "A dotgotbar.link" >> $testroot/stdout.expected
224 echo "A epsilon/new" >> $testroot/stdout.expected
225 echo "G gamma/delta" >> $testroot/stdout.expected
226 echo "A symlink" >> $testroot/stdout.expected
227 echo -n "Merged refs/heads/newbranch into refs/heads/master: " \
228 >> $testroot/stdout.expected
229 echo $merge_commit >> $testroot/stdout.expected
231 cmp -s $testroot/stdout.expected $testroot/stdout
233 if [ $ret -ne 0 ]; then
234 diff -u $testroot/stdout.expected $testroot/stdout
235 test_done "$testroot" "$ret"
239 echo "modified delta on branch" > $testroot/content.expected
240 cat $testroot/wt/gamma/delta > $testroot/content
241 cmp -s $testroot/content.expected $testroot/content
243 if [ $ret -ne 0 ]; then
244 diff -u $testroot/content.expected $testroot/content
245 test_done "$testroot" "$ret"
249 echo "modified alpha on branch" > $testroot/content.expected
250 cat $testroot/wt/alpha > $testroot/content
251 cmp -s $testroot/content.expected $testroot/content
253 if [ $ret -ne 0 ]; then
254 diff -u $testroot/content.expected $testroot/content
255 test_done "$testroot" "$ret"
259 if [ -e $testroot/wt/beta ]; then
260 echo "removed file beta still exists on disk" >&2
261 test_done "$testroot" "1"
265 echo "new file on branch" > $testroot/content.expected
266 cat $testroot/wt/epsilon/new > $testroot/content
267 cmp -s $testroot/content.expected $testroot/content
269 if [ $ret -ne 0 ]; then
270 diff -u $testroot/content.expected $testroot/content
271 test_done "$testroot" "$ret"
275 if [ ! -h $testroot/wt/dotgotbar.link ]; then
276 echo "dotgotbar.link is not a symlink"
277 test_done "$testroot" "1"
281 readlink $testroot/wt/symlink > $testroot/stdout
282 echo "alpha" > $testroot/stdout.expected
283 cmp -s $testroot/stdout.expected $testroot/stdout
285 if [ $ret -ne 0 ]; then
286 diff -u $testroot/stdout.expected $testroot/stdout
287 test_done "$testroot" "$ret"
291 (cd $testroot/wt && got status > $testroot/stdout)
293 echo -n > $testroot/stdout.expected
294 cmp -s $testroot/stdout.expected $testroot/stdout
296 if [ $ret -ne 0 ]; then
297 diff -u $testroot/stdout.expected $testroot/stdout
298 test_done "$testroot" "$ret"
302 (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
303 echo "commit $merge_commit (master)" > $testroot/stdout.expected
304 echo "commit $master_commit" >> $testroot/stdout.expected
305 echo "commit $commit0" >> $testroot/stdout.expected
306 cmp -s $testroot/stdout.expected $testroot/stdout
308 if [ $ret -ne 0 ]; then
309 diff -u $testroot/stdout.expected $testroot/stdout
310 test_done "$testroot" "$ret"
314 (cd $testroot/wt && got update > $testroot/stdout)
316 echo 'U dotgotbar.link' > $testroot/stdout.expected
317 echo -n "Updated to refs/heads/master: " >> $testroot/stdout.expected
318 git_show_head $testroot/repo >> $testroot/stdout.expected
319 echo >> $testroot/stdout.expected
320 cmp -s $testroot/stdout.expected $testroot/stdout
322 if [ $ret -ne 0 ]; then
323 diff -u $testroot/stdout.expected $testroot/stdout
324 test_done "$testroot" "$ret"
328 # update has changed the bad symlink into a regular file
329 if [ -h $testroot/wt/dotgotbar.link ]; then
330 echo "dotgotbar.link is a symlink"
331 test_done "$testroot" "1"
335 # We should have created a merge commit with two parents.
336 (cd $testroot/wt && got log -l1 | grep ^parent > $testroot/stdout)
337 echo "parent 1: $master_commit" > $testroot/stdout.expected
338 echo "parent 2: $branch_commit5" >> $testroot/stdout.expected
339 cmp -s $testroot/stdout.expected $testroot/stdout
341 if [ $ret -ne 0 ]; then
342 diff -u $testroot/stdout.expected $testroot/stdout
343 test_done "$testroot" "$ret"
347 got tree -r $testroot/repo -c $merge_commit -R > $testroot/stdout
349 if [ $ret -ne 0 ]; then
350 echo "got tree failed unexpectedly" >&2
351 test_done "$testroot" "$ret"
355 # bad symlink dotgotbar.link appears as a symlink in the merge commit:
356 cat > $testroot/stdout.expected <<EOF
358 dotgotbar.link@ -> .got/bar
366 cmp -s $testroot/stdout.expected $testroot/stdout
368 if [ $ret -ne 0 ]; then
369 diff -u $testroot/stdout.expected $testroot/stdout
371 test_done "$testroot" "$ret"
374 test_merge_continue() {
375 local testroot=`test_init merge_continue`
376 local commit0=`git_show_head $testroot/repo`
377 local commit0_author_time=`git_show_author_time $testroot/repo`
379 (cd $testroot/repo && git checkout -q -b newbranch)
380 echo "modified delta on branch" > $testroot/repo/gamma/delta
381 git_commit $testroot/repo -m "committing to delta on newbranch"
382 local branch_commit0=`git_show_branch_head $testroot/repo newbranch`
384 echo "modified alpha on branch" > $testroot/repo/alpha
385 git_commit $testroot/repo -m "committing to alpha on newbranch"
386 local branch_commit1=`git_show_branch_head $testroot/repo newbranch`
387 (cd $testroot/repo && git rm -q beta)
388 git_commit $testroot/repo -m "removing beta on newbranch"
389 local branch_commit2=`git_show_branch_head $testroot/repo newbranch`
390 echo "new file on branch" > $testroot/repo/epsilon/new
391 (cd $testroot/repo && git add epsilon/new)
392 git_commit $testroot/repo -m "adding new file on newbranch"
393 local branch_commit3=`git_show_branch_head $testroot/repo newbranch`
395 got checkout -b master $testroot/repo $testroot/wt > /dev/null
397 if [ $ret -ne 0 ]; then
398 echo "got checkout failed unexpectedly" >&2
399 test_done "$testroot" "$ret"
403 # create a conflicting commit
404 (cd $testroot/repo && git checkout -q master)
405 echo "modified alpha on master" > $testroot/repo/alpha
406 git_commit $testroot/repo -m "committing to alpha on master"
407 local master_commit=`git_show_head $testroot/repo`
409 # need an up-to-date work tree for 'got merge'
410 (cd $testroot/wt && got update > /dev/null)
412 if [ $ret -ne 0 ]; then
413 echo "got update failed unexpectedly" >&2
414 test_done "$testroot" "$ret"
418 (cd $testroot/wt && got merge newbranch \
419 > $testroot/stdout 2> $testroot/stderr)
421 if [ $ret -eq 0 ]; then
422 echo "got merge succeeded unexpectedly" >&2
423 test_done "$testroot" "1"
427 echo "C alpha" >> $testroot/stdout.expected
428 echo "D beta" >> $testroot/stdout.expected
429 echo "A epsilon/new" >> $testroot/stdout.expected
430 echo "G gamma/delta" >> $testroot/stdout.expected
431 echo "Files with new merge conflicts: 1" >> $testroot/stdout.expected
432 cmp -s $testroot/stdout.expected $testroot/stdout
434 if [ $ret -ne 0 ]; then
435 diff -u $testroot/stdout.expected $testroot/stdout
436 test_done "$testroot" "$ret"
440 echo "got: conflicts must be resolved before merging can continue" \
441 > $testroot/stderr.expected
442 cmp -s $testroot/stderr.expected $testroot/stderr
444 if [ $ret -ne 0 ]; then
445 diff -u $testroot/stderr.expected $testroot/stderr
446 test_done "$testroot" "$ret"
450 (cd $testroot/wt && got status > $testroot/stdout)
452 echo "C alpha" > $testroot/stdout.expected
453 echo "D beta" >> $testroot/stdout.expected
454 echo "A epsilon/new" >> $testroot/stdout.expected
455 echo "M gamma/delta" >> $testroot/stdout.expected
456 cmp -s $testroot/stdout.expected $testroot/stdout
458 if [ $ret -ne 0 ]; then
459 diff -u $testroot/stdout.expected $testroot/stdout
460 test_done "$testroot" "$ret"
464 echo '<<<<<<<' > $testroot/content.expected
465 echo "modified alpha on master" >> $testroot/content.expected
466 echo "||||||| 3-way merge base: commit $commit0" \
467 >> $testroot/content.expected
468 echo "alpha" >> $testroot/content.expected
469 echo "=======" >> $testroot/content.expected
470 echo "modified alpha on branch" >> $testroot/content.expected
471 echo ">>>>>>> merged change: commit $branch_commit3" \
472 >> $testroot/content.expected
473 cat $testroot/wt/alpha > $testroot/content
474 cmp -s $testroot/content.expected $testroot/content
476 if [ $ret -ne 0 ]; then
477 diff -u $testroot/content.expected $testroot/content
478 test_done "$testroot" "$ret"
482 # resolve the conflict
483 echo "modified alpha by both branches" > $testroot/wt/alpha
485 (cd $testroot/wt && got merge -c > $testroot/stdout)
487 if [ $ret -ne 0 ]; then
488 echo "got merge failed unexpectedly" >&2
489 test_done "$testroot" "$ret"
493 local merge_commit=`git_show_head $testroot/repo`
495 echo "M alpha" > $testroot/stdout.expected
496 echo "D beta" >> $testroot/stdout.expected
497 echo "A epsilon/new" >> $testroot/stdout.expected
498 echo "M gamma/delta" >> $testroot/stdout.expected
499 echo -n "Merged refs/heads/newbranch into refs/heads/master: " \
500 >> $testroot/stdout.expected
501 echo $merge_commit >> $testroot/stdout.expected
503 cmp -s $testroot/stdout.expected $testroot/stdout
505 if [ $ret -ne 0 ]; then
506 diff -u $testroot/stdout.expected $testroot/stdout
507 test_done "$testroot" "$ret"
511 echo "modified delta on branch" > $testroot/content.expected
512 cat $testroot/wt/gamma/delta > $testroot/content
513 cmp -s $testroot/content.expected $testroot/content
515 if [ $ret -ne 0 ]; then
516 diff -u $testroot/content.expected $testroot/content
517 test_done "$testroot" "$ret"
521 echo "modified alpha by both branches" > $testroot/content.expected
522 cat $testroot/wt/alpha > $testroot/content
523 cmp -s $testroot/content.expected $testroot/content
525 if [ $ret -ne 0 ]; then
526 diff -u $testroot/content.expected $testroot/content
527 test_done "$testroot" "$ret"
531 if [ -e $testroot/wt/beta ]; then
532 echo "removed file beta still exists on disk" >&2
533 test_done "$testroot" "1"
537 echo "new file on branch" > $testroot/content.expected
538 cat $testroot/wt/epsilon/new > $testroot/content
539 cmp -s $testroot/content.expected $testroot/content
541 if [ $ret -ne 0 ]; then
542 diff -u $testroot/content.expected $testroot/content
543 test_done "$testroot" "$ret"
547 (cd $testroot/wt && got status > $testroot/stdout)
549 echo -n > $testroot/stdout.expected
550 cmp -s $testroot/stdout.expected $testroot/stdout
552 if [ $ret -ne 0 ]; then
553 diff -u $testroot/stdout.expected $testroot/stdout
554 test_done "$testroot" "$ret"
558 (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
559 echo "commit $merge_commit (master)" > $testroot/stdout.expected
560 echo "commit $master_commit" >> $testroot/stdout.expected
561 echo "commit $commit0" >> $testroot/stdout.expected
562 cmp -s $testroot/stdout.expected $testroot/stdout
564 if [ $ret -ne 0 ]; then
565 diff -u $testroot/stdout.expected $testroot/stdout
566 test_done "$testroot" "$ret"
570 (cd $testroot/wt && got update > $testroot/stdout)
572 echo 'Already up-to-date' > $testroot/stdout.expected
573 cmp -s $testroot/stdout.expected $testroot/stdout
575 if [ $ret -ne 0 ]; then
576 diff -u $testroot/stdout.expected $testroot/stdout
577 test_done "$testroot" "$ret"
581 # We should have created a merge commit with two parents.
582 (cd $testroot/wt && got log -l1 | grep ^parent > $testroot/stdout)
583 echo "parent 1: $master_commit" > $testroot/stdout.expected
584 echo "parent 2: $branch_commit3" >> $testroot/stdout.expected
585 cmp -s $testroot/stdout.expected $testroot/stdout
587 if [ $ret -ne 0 ]; then
588 diff -u $testroot/stdout.expected $testroot/stdout
590 test_done "$testroot" "$ret"
594 local testroot=`test_init merge_abort`
595 local commit0=`git_show_head $testroot/repo`
596 local commit0_author_time=`git_show_author_time $testroot/repo`
598 (cd $testroot/repo && git checkout -q -b newbranch)
599 echo "modified delta on branch" > $testroot/repo/gamma/delta
600 git_commit $testroot/repo -m "committing to delta on newbranch"
601 local branch_commit0=`git_show_branch_head $testroot/repo newbranch`
603 echo "modified alpha on branch" > $testroot/repo/alpha
604 git_commit $testroot/repo -m "committing to alpha on newbranch"
605 local branch_commit1=`git_show_branch_head $testroot/repo newbranch`
606 (cd $testroot/repo && git rm -q beta)
607 git_commit $testroot/repo -m "removing beta on newbranch"
608 local branch_commit2=`git_show_branch_head $testroot/repo newbranch`
609 echo "new file on branch" > $testroot/repo/epsilon/new
610 (cd $testroot/repo && git add epsilon/new)
611 git_commit $testroot/repo -m "adding new file on newbranch"
612 local branch_commit3=`git_show_branch_head $testroot/repo newbranch`
613 (cd $testroot/repo && ln -s alpha symlink && git add symlink)
614 git_commit $testroot/repo -m "adding symlink on newbranch"
615 local branch_commit4=`git_show_branch_head $testroot/repo newbranch`
617 got checkout -b master $testroot/repo $testroot/wt > /dev/null
619 if [ $ret -ne 0 ]; then
620 echo "got checkout failed unexpectedly" >&2
621 test_done "$testroot" "$ret"
625 # unrelated unversioned file in work tree
626 touch $testroot/wt/unversioned-file
628 # create a conflicting commit
629 (cd $testroot/repo && git checkout -q master)
630 echo "modified alpha on master" > $testroot/repo/alpha
631 git_commit $testroot/repo -m "committing to alpha on master"
632 local master_commit=`git_show_head $testroot/repo`
634 # need an up-to-date work tree for 'got merge'
635 (cd $testroot/wt && got update > /dev/null)
637 if [ $ret -ne 0 ]; then
638 echo "got update failed unexpectedly" >&2
639 test_done "$testroot" "$ret"
643 (cd $testroot/wt && got merge newbranch \
644 > $testroot/stdout 2> $testroot/stderr)
646 if [ $ret -eq 0 ]; then
647 echo "got merge succeeded unexpectedly" >&2
648 test_done "$testroot" "1"
652 echo "C alpha" >> $testroot/stdout.expected
653 echo "D beta" >> $testroot/stdout.expected
654 echo "A epsilon/new" >> $testroot/stdout.expected
655 echo "G gamma/delta" >> $testroot/stdout.expected
656 echo "A symlink" >> $testroot/stdout.expected
657 echo "Files with new merge conflicts: 1" >> $testroot/stdout.expected
658 cmp -s $testroot/stdout.expected $testroot/stdout
660 if [ $ret -ne 0 ]; then
661 diff -u $testroot/stdout.expected $testroot/stdout
662 test_done "$testroot" "$ret"
666 echo "got: conflicts must be resolved before merging can continue" \
667 > $testroot/stderr.expected
668 cmp -s $testroot/stderr.expected $testroot/stderr
670 if [ $ret -ne 0 ]; then
671 diff -u $testroot/stderr.expected $testroot/stderr
672 test_done "$testroot" "$ret"
676 # unrelated added file added during conflict resolution
677 touch $testroot/wt/added-file
678 (cd $testroot/wt && got add added-file > /dev/null)
680 (cd $testroot/wt && got status > $testroot/stdout)
682 echo "A added-file" > $testroot/stdout.expected
683 echo "C alpha" >> $testroot/stdout.expected
684 echo "D beta" >> $testroot/stdout.expected
685 echo "A epsilon/new" >> $testroot/stdout.expected
686 echo "M gamma/delta" >> $testroot/stdout.expected
687 echo "A symlink" >> $testroot/stdout.expected
688 echo "? unversioned-file" >> $testroot/stdout.expected
689 cmp -s $testroot/stdout.expected $testroot/stdout
691 if [ $ret -ne 0 ]; then
692 diff -u $testroot/stdout.expected $testroot/stdout
693 test_done "$testroot" "$ret"
697 (cd $testroot/wt && got merge -a > $testroot/stdout)
699 if [ $ret -ne 0 ]; then
700 echo "got merge failed unexpectedly" >&2
701 test_done "$testroot" "$ret"
705 echo "R added-file" > $testroot/stdout.expected
706 echo "R alpha" >> $testroot/stdout.expected
707 echo "R beta" >> $testroot/stdout.expected
708 echo "R epsilon/new" >> $testroot/stdout.expected
709 echo "R gamma/delta" >> $testroot/stdout.expected
710 echo "R symlink" >> $testroot/stdout.expected
711 echo "G added-file" >> $testroot/stdout.expected
712 echo "Merge of refs/heads/newbranch aborted" \
713 >> $testroot/stdout.expected
715 cmp -s $testroot/stdout.expected $testroot/stdout
717 if [ $ret -ne 0 ]; then
718 diff -u $testroot/stdout.expected $testroot/stdout
719 test_done "$testroot" "$ret"
723 echo "delta" > $testroot/content.expected
724 cat $testroot/wt/gamma/delta > $testroot/content
725 cmp -s $testroot/content.expected $testroot/content
727 if [ $ret -ne 0 ]; then
728 diff -u $testroot/content.expected $testroot/content
729 test_done "$testroot" "$ret"
733 echo "modified alpha on master" > $testroot/content.expected
734 cat $testroot/wt/alpha > $testroot/content
735 cmp -s $testroot/content.expected $testroot/content
737 if [ $ret -ne 0 ]; then
738 diff -u $testroot/content.expected $testroot/content
739 test_done "$testroot" "$ret"
743 echo "beta" > $testroot/content.expected
744 cat $testroot/wt/beta > $testroot/content
745 cmp -s $testroot/content.expected $testroot/content
747 if [ $ret -ne 0 ]; then
748 diff -u $testroot/content.expected $testroot/content
749 test_done "$testroot" "$ret"
753 if [ -e $testroot/wt/epsilon/new ]; then
754 echo "reverted file epsilon/new still exists on disk" >&2
755 test_done "$testroot" "1"
759 if [ -e $testroot/wt/symlink ]; then
760 echo "reverted symlink still exists on disk" >&2
761 test_done "$testroot" "1"
765 (cd $testroot/wt && got status > $testroot/stdout)
767 echo "? added-file" > $testroot/stdout.expected
768 echo "? unversioned-file" >> $testroot/stdout.expected
769 cmp -s $testroot/stdout.expected $testroot/stdout
771 if [ $ret -ne 0 ]; then
772 diff -u $testroot/stdout.expected $testroot/stdout
773 test_done "$testroot" "$ret"
777 (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
778 echo "commit $master_commit (master)" > $testroot/stdout.expected
779 echo "commit $commit0" >> $testroot/stdout.expected
780 cmp -s $testroot/stdout.expected $testroot/stdout
782 if [ $ret -ne 0 ]; then
783 diff -u $testroot/stdout.expected $testroot/stdout
784 test_done "$testroot" "$ret"
788 (cd $testroot/wt && got update > $testroot/stdout)
790 echo 'Already up-to-date' > $testroot/stdout.expected
791 cmp -s $testroot/stdout.expected $testroot/stdout
793 if [ $ret -ne 0 ]; then
794 diff -u $testroot/stdout.expected $testroot/stdout
796 test_done "$testroot" "$ret"
799 test_merge_in_progress() {
800 local testroot=`test_init merge_in_progress`
801 local commit0=`git_show_head $testroot/repo`
802 local commit0_author_time=`git_show_author_time $testroot/repo`
804 (cd $testroot/repo && git checkout -q -b newbranch)
805 echo "modified alpha on branch" > $testroot/repo/alpha
806 git_commit $testroot/repo -m "committing to alpha on newbranch"
807 local branch_commit0=`git_show_branch_head $testroot/repo newbranch`
809 got checkout -b master $testroot/repo $testroot/wt > /dev/null
811 if [ $ret -ne 0 ]; then
812 echo "got checkout failed unexpectedly" >&2
813 test_done "$testroot" "$ret"
817 # create a conflicting commit
818 (cd $testroot/repo && git checkout -q master)
819 echo "modified alpha on master" > $testroot/repo/alpha
820 git_commit $testroot/repo -m "committing to alpha on master"
821 local master_commit=`git_show_head $testroot/repo`
823 # need an up-to-date work tree for 'got merge'
824 (cd $testroot/wt && got update > /dev/null)
826 if [ $ret -ne 0 ]; then
827 echo "got update failed unexpectedly" >&2
828 test_done "$testroot" "$ret"
832 (cd $testroot/wt && got merge newbranch \
833 > $testroot/stdout 2> $testroot/stderr)
835 if [ $ret -eq 0 ]; then
836 echo "got merge succeeded unexpectedly" >&2
837 test_done "$testroot" "1"
841 echo "C alpha" >> $testroot/stdout.expected
842 echo "Files with new merge conflicts: 1" >> $testroot/stdout.expected
843 cmp -s $testroot/stdout.expected $testroot/stdout
845 if [ $ret -ne 0 ]; then
846 diff -u $testroot/stdout.expected $testroot/stdout
847 test_done "$testroot" "$ret"
851 echo "got: conflicts must be resolved before merging can continue" \
852 > $testroot/stderr.expected
853 cmp -s $testroot/stderr.expected $testroot/stderr
855 if [ $ret -ne 0 ]; then
856 diff -u $testroot/stderr.expected $testroot/stderr
857 test_done "$testroot" "$ret"
861 (cd $testroot/wt && got status > $testroot/stdout)
863 echo "C alpha" > $testroot/stdout.expected
864 cmp -s $testroot/stdout.expected $testroot/stdout
866 if [ $ret -ne 0 ]; then
867 diff -u $testroot/stdout.expected $testroot/stdout
868 test_done "$testroot" "$ret"
872 for cmd in update commit histedit "rebase newbranch" \
873 "integrate newbranch" "stage alpha"; do
874 (cd $testroot/wt && got $cmd > $testroot/stdout \
877 echo -n > $testroot/stdout.expected
878 cmp -s $testroot/stdout.expected $testroot/stdout
880 if [ $ret -ne 0 ]; then
881 diff -u $testroot/stdout.expected $testroot/stdout
882 test_done "$testroot" "$ret"
886 echo -n "got: a merge operation is in progress in this " \
887 > $testroot/stderr.expected
888 echo "work tree and must be continued or aborted first" \
889 >> $testroot/stderr.expected
890 cmp -s $testroot/stderr.expected $testroot/stderr
892 if [ $ret -ne 0 ]; then
893 diff -u $testroot/stderr.expected $testroot/stderr
894 test_done "$testroot" "$ret"
899 test_done "$testroot" "$ret"
902 test_merge_path_prefix() {
903 local testroot=`test_init merge_path_prefix`
904 local commit0=`git_show_head $testroot/repo`
905 local commit0_author_time=`git_show_author_time $testroot/repo`
907 (cd $testroot/repo && git checkout -q -b newbranch)
908 echo "modified alpha on branch" > $testroot/repo/alpha
909 git_commit $testroot/repo -m "committing to alpha on newbranch"
910 local branch_commit0=`git_show_branch_head $testroot/repo newbranch`
912 got checkout -p epsilon -b master $testroot/repo $testroot/wt \
915 if [ $ret -ne 0 ]; then
916 echo "got checkout failed unexpectedly" >&2
917 test_done "$testroot" "$ret"
921 # create a conflicting commit
922 (cd $testroot/repo && git checkout -q master)
923 echo "modified alpha on master" > $testroot/repo/alpha
924 git_commit $testroot/repo -m "committing to alpha on master"
925 local master_commit=`git_show_head $testroot/repo`
927 # need an up-to-date work tree for 'got merge'
928 (cd $testroot/wt && got update > /dev/null)
930 if [ $ret -ne 0 ]; then
931 echo "got update failed unexpectedly" >&2
932 test_done "$testroot" "$ret"
936 (cd $testroot/wt && got merge newbranch \
937 > $testroot/stdout 2> $testroot/stderr)
939 if [ $ret -eq 0 ]; then
940 echo "got merge succeeded unexpectedly" >&2
941 test_done "$testroot" "1"
945 echo -n "got: cannot merge branch which contains changes outside " \
946 > $testroot/stderr.expected
947 echo "of this work tree's path prefix" >> $testroot/stderr.expected
948 cmp -s $testroot/stderr.expected $testroot/stderr
950 if [ $ret -ne 0 ]; then
951 diff -u $testroot/stderr.expected $testroot/stderr
953 test_done "$testroot" "$ret"
956 test_merge_missing_file() {
957 local testroot=`test_init merge_missing_file`
958 local commit0=`git_show_head $testroot/repo`
959 local commit0_author_time=`git_show_author_time $testroot/repo`
961 (cd $testroot/repo && git checkout -q -b newbranch)
962 echo "modified alpha on branch" > $testroot/repo/alpha
963 echo "modified delta on branch" > $testroot/repo/gamma/delta
964 git_commit $testroot/repo -m "committing to alpha and delta"
965 local branch_commit0=`git_show_branch_head $testroot/repo newbranch`
967 got checkout -b master $testroot/repo $testroot/wt > /dev/null
969 if [ $ret -ne 0 ]; then
970 echo "got checkout failed unexpectedly" >&2
971 test_done "$testroot" "$ret"
975 # create a conflicting commit which renames alpha
976 (cd $testroot/repo && git checkout -q master)
977 (cd $testroot/repo && git mv alpha epsilon/alpha-moved)
978 git_commit $testroot/repo -m "moving alpha on master"
979 local master_commit=`git_show_head $testroot/repo`
981 # need an up-to-date work tree for 'got merge'
982 (cd $testroot/wt && got update > /dev/null)
984 if [ $ret -ne 0 ]; then
985 echo "got update failed unexpectedly" >&2
986 test_done "$testroot" "$ret"
990 (cd $testroot/wt && got merge newbranch \
991 > $testroot/stdout 2> $testroot/stderr)
993 if [ $ret -eq 0 ]; then
994 echo "got merge succeeded unexpectedly" >&2
995 test_done "$testroot" "1"
999 echo "! alpha" > $testroot/stdout.expected
1000 echo "G gamma/delta" >> $testroot/stdout.expected
1001 echo -n "Files which had incoming changes but could not be found " \
1002 >> $testroot/stdout.expected
1003 echo "in the work tree: 1" >> $testroot/stdout.expected
1004 cmp -s $testroot/stdout.expected $testroot/stdout
1006 if [ $ret -ne 0 ]; then
1007 diff -u $testroot/stdout.expected $testroot/stdout
1008 test_done "$testroot" "$ret"
1012 echo -n "got: changes destined for some files " \
1013 > $testroot/stderr.expected
1014 echo -n "were not yet merged and should be merged manually if " \
1015 >> $testroot/stderr.expected
1016 echo "required before the merge operation is continued" \
1017 >> $testroot/stderr.expected
1018 cmp -s $testroot/stderr.expected $testroot/stderr
1020 if [ $ret -ne 0 ]; then
1021 diff -u $testroot/stderr.expected $testroot/stderr
1022 test_done "$testroot" "$ret"
1026 (cd $testroot/wt && got status > $testroot/stdout)
1028 echo "M gamma/delta" > $testroot/stdout.expected
1029 cmp -s $testroot/stdout.expected $testroot/stdout
1031 if [ $ret -ne 0 ]; then
1032 diff -u $testroot/stdout.expected $testroot/stdout
1033 test_done "$testroot" "$ret"
1037 test_done "$testroot" "$ret"
1040 test_merge_no_op() {
1041 local testroot=`test_init merge_no_op`
1042 local commit0=`git_show_head $testroot/repo`
1043 local commit0_author_time=`git_show_author_time $testroot/repo`
1045 (cd $testroot/repo && git checkout -q -b newbranch)
1046 echo "modified alpha on branch" > $testroot/repo/alpha
1047 git_commit $testroot/repo -m "committing to alpha on newbranch"
1048 local branch_commitk=`git_show_branch_head $testroot/repo newbranch`
1050 got checkout -b master $testroot/repo $testroot/wt > /dev/null
1052 if [ $ret -ne 0 ]; then
1053 echo "got checkout failed unexpectedly" >&2
1054 test_done "$testroot" "$ret"
1058 # create a conflicting commit
1059 (cd $testroot/repo && git checkout -q master)
1060 echo "modified alpha on master" > $testroot/repo/alpha
1061 git_commit $testroot/repo -m "committing to alpha on master"
1062 local master_commit=`git_show_head $testroot/repo`
1064 # need an up-to-date work tree for 'got merge'
1065 (cd $testroot/wt && got update > /dev/null)
1067 if [ $ret -ne 0 ]; then
1068 echo "got update failed unexpectedly" >&2
1069 test_done "$testroot" "$ret"
1073 (cd $testroot/wt && got merge newbranch \
1074 > $testroot/stdout 2> $testroot/stderr)
1076 if [ $ret -eq 0 ]; then
1077 echo "got merge succeeded unexpectedly" >&2
1078 test_done "$testroot" "1"
1082 echo "C alpha" >> $testroot/stdout.expected
1083 echo "Files with new merge conflicts: 1" >> $testroot/stdout.expected
1084 cmp -s $testroot/stdout.expected $testroot/stdout
1086 if [ $ret -ne 0 ]; then
1087 diff -u $testroot/stdout.expected $testroot/stdout
1088 test_done "$testroot" "$ret"
1092 echo "got: conflicts must be resolved before merging can continue" \
1093 > $testroot/stderr.expected
1094 cmp -s $testroot/stderr.expected $testroot/stderr
1096 if [ $ret -ne 0 ]; then
1097 diff -u $testroot/stderr.expected $testroot/stderr
1098 test_done "$testroot" "$ret"
1102 (cd $testroot/wt && got status > $testroot/stdout)
1104 echo "C alpha" > $testroot/stdout.expected
1105 cmp -s $testroot/stdout.expected $testroot/stdout
1107 if [ $ret -ne 0 ]; then
1108 diff -u $testroot/stdout.expected $testroot/stdout
1109 test_done "$testroot" "$ret"
1113 # resolve the conflict by reverting all changes; now it is no-op merge
1114 (cd $testroot/wt && got revert alpha > /dev/null)
1116 if [ $ret -ne 0 ]; then
1117 echo "got revert failed unexpectedly" >&2
1118 test_done "$testroot" "$ret"
1122 (cd $testroot/wt && got merge -c > $testroot/stdout \
1123 2> $testroot/stderr)
1125 if [ $ret -eq 0 ]; then
1126 echo "got merge succeeded unexpectedly" >&2
1127 test_done "$testroot" "$ret"
1131 echo -n "got: merge of refs/heads/newbranch cannot proceed: " \
1132 > $testroot/stderr.expected
1133 echo "no changes to commit" >> $testroot/stderr.expected
1134 cmp -s $testroot/stderr.expected $testroot/stderr
1136 if [ $ret -ne 0 ]; then
1137 diff -u $testroot/stderr.expected $testroot/stderr
1138 test_done "$testroot" "$ret"
1142 (cd $testroot/wt && got status > $testroot/stdout)
1144 echo -n "" > $testroot/stdout.expected
1145 cmp -s $testroot/stdout.expected $testroot/stdout
1147 if [ $ret -ne 0 ]; then
1148 diff -u $testroot/stdout.expected $testroot/stdout
1150 test_done "$testroot" "$ret"
1153 test_merge_imported_branch() {
1154 local testroot=`test_init merge_import`
1155 local commit0=`git_show_head $testroot/repo`
1156 local commit0_author_time=`git_show_author_time $testroot/repo`
1158 # import a new sub-tree to the 'files' branch such that
1159 # none of the files added here collide with existing ones
1160 mkdir -p $testroot/tree/there
1161 mkdir -p $testroot/tree/be/lots
1162 mkdir -p $testroot/tree/files
1163 echo "there should" > $testroot/tree/there/should
1164 echo "be lots of" > $testroot/tree/be/lots/of
1165 echo "files here" > $testroot/tree/files/here
1166 got import -r $testroot/repo -b files -m 'import files' \
1167 $testroot/tree > /dev/null
1169 got checkout -b master $testroot/repo $testroot/wt > /dev/null
1171 if [ $ret -ne 0 ]; then
1172 echo "got checkout failed unexpectedly" >&2
1173 test_done "$testroot" "$ret"
1177 (cd $testroot/wt && got merge files > $testroot/stdout)
1179 if [ $ret -ne 0 ]; then
1180 echo "got merge failed unexpectedly" >&2
1181 test_done "$testroot" "$ret"
1185 local merge_commit0=`git_show_head $testroot/repo`
1186 cat > $testroot/stdout.expected <<EOF
1190 Merged refs/heads/files into refs/heads/master: $merge_commit0
1192 cmp -s $testroot/stdout.expected $testroot/stdout
1194 if [ $ret -ne 0 ]; then
1195 diff -u $testroot/stdout.expected $testroot/stdout
1196 test_done "$testroot" "$ret"
1200 # try to merge again while no new changes are available
1201 (cd $testroot/wt && got merge files > $testroot/stdout)
1203 if [ $ret -ne 0 ]; then
1204 echo "got merge failed unexpectedly" >&2
1205 test_done "$testroot" "$ret"
1208 echo "Already up-to-date" > $testroot/stdout.expected
1209 cmp -s $testroot/stdout.expected $testroot/stdout
1211 if [ $ret -ne 0 ]; then
1212 diff -u $testroot/stdout.expected $testroot/stdout
1213 test_done "$testroot" "$ret"
1217 # update the 'files' branch
1218 (cd $testroot/repo && git reset -q --hard master)
1219 (cd $testroot/repo && git checkout -q files)
1220 echo "indeed" > $testroot/repo/indeed
1221 (cd $testroot/repo && git add indeed)
1222 git_commit $testroot/repo -m "adding another file indeed"
1223 echo "be lots and lots of" > $testroot/repo/be/lots/of
1224 git_commit $testroot/repo -m "lots of changes"
1226 (cd $testroot/wt && got update > /dev/null)
1228 if [ $ret -ne 0 ]; then
1229 echo "got update failed unexpectedly" >&2
1230 test_done "$testroot" "$ret"
1234 # we should now be able to merge more changes from files branch
1235 (cd $testroot/wt && got merge files > $testroot/stdout)
1237 if [ $ret -ne 0 ]; then
1238 echo "got merge failed unexpectedly" >&2
1239 test_done "$testroot" "$ret"
1243 local merge_commit1=`git_show_branch_head $testroot/repo master`
1244 cat > $testroot/stdout.expected <<EOF
1247 Merged refs/heads/files into refs/heads/master: $merge_commit1
1250 cmp -s $testroot/stdout.expected $testroot/stdout
1252 if [ $ret -ne 0 ]; then
1253 diff -u $testroot/stdout.expected $testroot/stdout
1255 test_done "$testroot" "$ret"
1258 test_merge_interrupt() {
1259 local testroot=`test_init merge_interrupt`
1260 local commit0=`git_show_head $testroot/repo`
1261 local commit0_author_time=`git_show_author_time $testroot/repo`
1263 (cd $testroot/repo && git checkout -q -b newbranch)
1264 echo "modified alpha on branch" > $testroot/repo/alpha
1265 git_commit $testroot/repo -m "committing to alpha on newbranch"
1266 local branch_commit0=`git_show_branch_head $testroot/repo newbranch`
1268 got checkout -b master $testroot/repo $testroot/wt > /dev/null
1270 if [ $ret -ne 0 ]; then
1271 echo "got checkout failed unexpectedly" >&2
1272 test_done "$testroot" "$ret"
1276 # create a non-conflicting commit
1277 (cd $testroot/repo && git checkout -q master)
1278 echo "modified beta on master" > $testroot/repo/beta
1279 git_commit $testroot/repo -m "committing to beta on master"
1280 local master_commit=`git_show_head $testroot/repo`
1282 # need an up-to-date work tree for 'got merge'
1283 (cd $testroot/wt && got update > /dev/null)
1285 if [ $ret -ne 0 ]; then
1286 echo "got update failed unexpectedly" >&2
1287 test_done "$testroot" "$ret"
1291 (cd $testroot/wt && got merge -n newbranch \
1292 > $testroot/stdout 2> $testroot/stderr)
1294 if [ $ret -ne 0 ]; then
1295 echo "got merge failed unexpectedly" >&2
1296 test_done "$testroot" "1"
1300 echo "G alpha" > $testroot/stdout.expected
1301 echo "Merge of refs/heads/newbranch interrupted on request" \
1302 >> $testroot/stdout.expected
1303 cmp -s $testroot/stdout.expected $testroot/stdout
1305 if [ $ret -ne 0 ]; then
1306 diff -u $testroot/stdout.expected $testroot/stdout
1307 test_done "$testroot" "$ret"
1311 (cd $testroot/wt && got status > $testroot/stdout)
1313 echo "M alpha" > $testroot/stdout.expected
1314 cmp -s $testroot/stdout.expected $testroot/stdout
1316 if [ $ret -ne 0 ]; then
1317 diff -u $testroot/stdout.expected $testroot/stdout
1318 test_done "$testroot" "$ret"
1322 echo "modified alpha on branch" > $testroot/content.expected
1323 cat $testroot/wt/alpha > $testroot/content
1324 cmp -s $testroot/content.expected $testroot/content
1326 if [ $ret -ne 0 ]; then
1327 diff -u $testroot/content.expected $testroot/content
1328 test_done "$testroot" "$ret"
1332 # adjust merge result
1333 echo "adjusted merge result" > $testroot/wt/alpha
1335 # continue the merge
1336 (cd $testroot/wt && got merge -c > $testroot/stdout)
1338 if [ $ret -ne 0 ]; then
1339 echo "got merge failed unexpectedly" >&2
1340 test_done "$testroot" "$ret"
1344 local merge_commit=`git_show_head $testroot/repo`
1346 echo "M alpha" > $testroot/stdout.expected
1347 echo -n "Merged refs/heads/newbranch into refs/heads/master: " \
1348 >> $testroot/stdout.expected
1349 echo $merge_commit >> $testroot/stdout.expected
1351 cmp -s $testroot/stdout.expected $testroot/stdout
1353 if [ $ret -ne 0 ]; then
1354 diff -u $testroot/stdout.expected $testroot/stdout
1355 test_done "$testroot" "$ret"
1359 (cd $testroot/wt && got status > $testroot/stdout)
1361 echo -n > $testroot/stdout.expected
1362 cmp -s $testroot/stdout.expected $testroot/stdout
1364 if [ $ret -ne 0 ]; then
1365 diff -u $testroot/stdout.expected $testroot/stdout
1366 test_done "$testroot" "$ret"
1370 (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
1371 echo "commit $merge_commit (master)" > $testroot/stdout.expected
1372 echo "commit $master_commit" >> $testroot/stdout.expected
1373 echo "commit $commit0" >> $testroot/stdout.expected
1374 cmp -s $testroot/stdout.expected $testroot/stdout
1376 if [ $ret -ne 0 ]; then
1377 diff -u $testroot/stdout.expected $testroot/stdout
1378 test_done "$testroot" "$ret"
1382 (cd $testroot/wt && got update > $testroot/stdout)
1384 echo 'Already up-to-date' > $testroot/stdout.expected
1385 cmp -s $testroot/stdout.expected $testroot/stdout
1387 if [ $ret -ne 0 ]; then
1388 diff -u $testroot/stdout.expected $testroot/stdout
1389 test_done "$testroot" "$ret"
1393 # We should have created a merge commit with two parents.
1394 (cd $testroot/wt && got log -l1 | grep ^parent > $testroot/stdout)
1395 echo "parent 1: $master_commit" > $testroot/stdout.expected
1396 echo "parent 2: $branch_commit0" >> $testroot/stdout.expected
1397 cmp -s $testroot/stdout.expected $testroot/stdout
1399 if [ $ret -ne 0 ]; then
1400 diff -u $testroot/stdout.expected $testroot/stdout
1402 test_done "$testroot" "$ret"
1405 test_merge_umask() {
1406 local testroot=`test_init merge_umask`
1408 (cd $testroot/repo && git checkout -q -b newbranch)
1409 echo "modified alpha on branch" >$testroot/repo/alpha
1410 git_commit "$testroot/repo" -m "committing alpha on newbranch"
1411 echo "modified delta on branch" >$testroot/repo/gamma/delta
1412 git_commit "$testroot/repo" -m "committing delta on newbranch"
1414 # diverge from newbranch
1415 (cd "$testroot/repo" && git checkout -q master)
1416 echo "modified beta on master" >$testroot/repo/beta
1417 git_commit "$testroot/repo" -m "committing zeto no master"
1419 got checkout "$testroot/repo" "$testroot/wt" >/dev/null
1421 # using a subshell to avoid clobbering global umask
1422 (umask 077 && cd "$testroot/wt" && got merge newbranch) >/dev/null
1424 for f in alpha gamma/delta; do
1425 ls -l "$testroot/wt/$f" | grep -q ^-rw-------
1426 if [ $? -ne 0 ]; then
1427 echo "$f is not 0600 after merge" >&2
1428 ls -l "$testroot/wt/$f" >&2
1429 test_done "$testroot" 1
1433 test_done "$testroot" 0
1436 test_merge_gitconfig_author() {
1437 local testroot=`test_init merge_gitconfig_author`
1439 (cd $testroot/repo && git config user.name 'Flan Luck')
1440 (cd $testroot/repo && git config user.email 'flan_luck@openbsd.org')
1442 (cd $testroot/repo && git checkout -q -b newbranch)
1443 echo "modified alpha on branch" >$testroot/repo/alpha
1444 git_commit "$testroot/repo" -m "committing alpha on newbranch"
1445 echo "modified delta on branch" >$testroot/repo/gamma/delta
1446 git_commit "$testroot/repo" -m "committing delta on newbranch"
1448 # diverge from newbranch
1449 (cd "$testroot/repo" && git checkout -q master)
1450 echo "modified beta on master" >$testroot/repo/beta
1451 git_commit "$testroot/repo" -m "committing zeto no master"
1453 got checkout "$testroot/repo" "$testroot/wt" >/dev/null
1455 # unset in a subshell to avoid affecting our environment
1456 (unset GOT_IGNORE_GITCONFIG && cd $testroot/wt && \
1457 got merge newbranch > /dev/null)
1459 (cd $testroot/repo && got log -l1 | grep ^from: > $testroot/stdout)
1461 if [ $ret -ne 0 ]; then
1462 test_done "$testroot" "$ret"
1466 echo "from: Flan Luck <flan_luck@openbsd.org>" \
1467 > $testroot/stdout.expected
1468 cmp -s $testroot/stdout.expected $testroot/stdout
1470 if [ $ret -ne 0 ]; then
1471 diff -u $testroot/stdout.expected $testroot/stdout
1473 test_done "$testroot" "$ret"
1477 run_test test_merge_basic
1478 run_test test_merge_continue
1479 run_test test_merge_abort
1480 run_test test_merge_in_progress
1481 run_test test_merge_path_prefix
1482 run_test test_merge_missing_file
1483 run_test test_merge_no_op
1484 run_test test_merge_imported_branch
1485 run_test test_merge_interrupt
1486 run_test test_merge_umask
1487 run_test test_merge_gitconfig_author