ref: e43ded677ea2a176f637ce90a6fa1b2ec038d09b
dir: /merge/
#!/bin/rc -e rfork ne . /sys/lib/git/common.rc fn merge{ ourbr=$1/tree basebr=$2/tree theirbr=$3/tree all=`{walk -f $ourbr $basebr $theirbr | \ subst -g '^('$ourbr'|'$basebr'|'$theirbr')/*' | sort | uniq} for(f in $all){ ours=$ourbr/$f base=$basebr/$f theirs=$theirbr/$f if(! test -f $ourbr/$f) ours=/dev/null if(! test -f $basebr/$f) base=/dev/null if(! test -f $theirbr/$f) theirs=/dev/null if(! ape/diff3 -m $ours $base $theirs > $f) echo merge needed: $f if(test -f $f) /$cputype/bin/git/add $f if not /$cputype/bin/git/rm $f } } gitup flagfmt=''; args='theirs' eval `''{aux/getflags $*} || exec aux/usage if(! ~ $#* 1) exec aux/usage theirs=`{/$cputytpe/bin/git/query $1} ours=`{/$cputype/bin/git/query HEAD} base=`{/$cputype/bin/git/query $theirs ^ ' ' ^ $ours ^ '@'} if(~ $base $theirs) die 'nothing to merge, doofus' if(! /$cputype/bin/git/walk -q) die 'dirty work tree, refusing to merge' if(~ $base $ours){ >[1=2] echo 'fast forwarding...' echo $theirs > .git/refs/`{/$cputype/bin/git/branch} /$cputype/bin/git/revert . exit '' } echo $ours >> .git/index9/merge-parents echo $theirs >> .git/index9/merge-parents merge /mnt/git/object/$ours /mnt/git/object/$base /mnt/git/object/$theirs >[1=2] echo 'merge complete: remember to commit' exit ''