git: got git?

Add a snapshot of git9 to 9front.
This commit is contained in:
Ori Bernstein 2021-05-16 18:49:45 -07:00
parent 013b2cad19
commit 1ee1bfaa8c
36 changed files with 9308 additions and 0 deletions

47
sys/src/cmd/git/merge Executable file
View file

@ -0,0 +1,47 @@
#!/bin/rc -e
rfork ne
. /sys/lib/git/common.rc
fn merge{
ourbr=/mnt/git/object/$1/tree
basebr=/mnt/git/object/$2/tree
theirbr=/mnt/git/object/$3/tree
all=`$nl{{git/query -c $1 $2; git/query -c $2 $3} | sed 's/^..//' | \
subst -g '^('$ourbr'|'$basebr'|'$theirbr')/*' | sort | uniq}
for(f in $all){
ours=$ourbr/$f
base=$basebr/$f
theirs=$theirbr/$f
merge1 $f $theirs $base $ours
}
}
gitup
flagfmt=''; args='theirs'
eval `''{aux/getflags $*} || exec aux/usage
if(! ~ $#* 1)
exec aux/usage
theirs=`{git/query $1}
ours=`{git/query HEAD}
base=`{git/query $theirs ^ ' ' ^ $ours ^ '@'}
if(~ $base $theirs)
die 'nothing to merge, doofus'
if(! git/walk -q)
die 'dirty work tree, refusing to merge'
if(~ $base $ours){
>[1=2] echo 'fast forwarding...'
echo $theirs > .git/refs/`{git/branch}
git/revert .
exit ''
}
echo $ours >> .git/index9/merge-parents
echo $theirs >> .git/index9/merge-parents
merge $ours $base $theirs
>[1=2] echo 'merge complete: remember to commit'
exit ''