shithub: git9

ref: 04dcec15808653507789cf4d2a50a9e1ff7f26cc
dir: /merge/

View raw version
#!/bin/rc
rfork ne
. /sys/lib/git/common.rc

usage='
	git/merge theirs
'

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
	}
}

gitup

if(! ~ $#* 1)
	usage

theirs=`{git/query $1}
ours=`{git/query HEAD}
base=`{git/query $theirs ^ ' ' ^ $ours ^ '@'}

if(~ $base $ours || ~ $base $theirs)
	die 'nothing to merge, doofus'
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