ref: 777e9c6d56ed9eaeb28196b3b6da77a34139f892
parent: 1fe21fede65b2cc7d72dd266a91492be5a71f025
author: Ori Bernstein <[email protected]>
date: Thu Sep 3 20:25:38 EDT 2020
scripts: use full path to git binaries This prepares us for the git/compat script, which will bind itself over /bin/git, as a way of providing a compatibility script for tools like go. Because /bin/git will be replaced, when in the compat environment, we will not be able to invoke git/foo.
--- a/branch
+++ b/branch
@@ -30,18 +30,18 @@
new=refs/heads/$branch
if (~ $#baseref 1)
- base=`{git/query $baseref} || exit 'bad base'
+ base=`{/$cputype/bin/git/query $baseref} || exit 'bad base'
if not if(test -e .git/$new)
- base=`{git/query $new}
+ base=`{/$cputype/bin/git/query $new}
if not
- base=`{git/query HEAD}
+ base=`{/$cputype/bin/git/query HEAD}
-modified=`$nl{git/query -c HEAD $base | grep '^[^-]' | subst '^..'}
-deleted=`$nl{git/query -c HEAD $base | grep '^-' | subst '^..'}
+modified=`$nl{/$cputype/bin/git/query -c HEAD $base | grep '^[^-]' | subst '^..'}
+deleted=`$nl{/$cputype/bin/git/query -c HEAD $base | grep '^-' | subst '^..'}
if(! ~ $#modified 0 || ! ~ $#deleted 0){
- if(! git/walk -q $modified $deleted){
- git/walk -fRMA $modified $deleted
+ if(! /$cputype/bin/git/walk -q $modified $deleted){
+ /$cputype/bin/git/walk -fRMA $modified $deleted
die 'uncommited changes would be clobbered'
}
}
@@ -56,7 +56,7 @@
if(! ~ $#baseref 0)
die update would clobber $branch with $baseref
}
-commit=`{git/query $base} || die 'branch does not exist:' $base
+commit=`{/$cputype/bin/git/query $base} || die 'branch does not exist:' $base
echo updating $new to $commit
echo $commit > .git/$new
@@ -65,7 +65,7 @@
exit
if(! ~ $#modified 0){
- basedir=`{git/query -p $base}
+ basedir=`{/$cputype/bin/git/query -p $base}
for(m in $modified){
d=`{basename -d $m}
mkdir -p $d
--- a/clone
+++ b/clone
@@ -30,7 +30,7 @@
echo ' url='$remote
echo ' fetch=+refs/heads/*:refs/remotes/origin/*'
}
- {git/fetch $remote >[2=3] | awk '
+ {/$cputype/bin/git/fetch $remote >[2=3] | awk '
/^remote/{
if($2=="HEAD"){
headhash=$3
@@ -64,12 +64,12 @@
'} |[3] tr '\x0d' '\x0a' || die 'could not clone repository'
tree=/mnt/git/HEAD/tree
- lbranch=`{git/branch}
+ lbranch=`{/$cputype/bin/git/branch}
rbranch=`{echo $lbranch | subst '^heads' 'remotes/origin'}
echo checking out repository...
if(test -f .git/refs/$rbranch){
cp .git/refs/$rbranch .git/refs/$lbranch
- git/fs
+ /$cputype/bin/git/fs
@ {builtin cd $tree && tar cif /fd/1 .} | @ {tar xf /fd/0} \
|| die 'checkout failed:' $status
for(f in `$nl{walk -f $tree | subst '^'$tree'/*'}){
--- a/commit
+++ b/commit
@@ -3,8 +3,8 @@
. /sys/lib/git/common.rc
fn whoami{
- name=`{git/conf user.name}
- email=`{git/conf user.email}
+ name=`{/$cputype/bin/git/conf user.name}
+ email=`{/$cputype/bin/git/conf user.email}
if(test -f /adm/keys.who){
if(~ $name '')
name=`{awk -F'|' '$1=="'$user'" {x=$3} END{print x}' </adm/keys.who}
@@ -18,7 +18,7 @@
}
fn findbranch{
- branch=`{git/branch}
+ branch=`{/$cputype/bin/git/branch}
if(test -e /mnt/git/branch/$branch/tree){
refpath=.git/refs/$branch
initial=false
@@ -58,11 +58,11 @@
echo '#'
for(p in $parents)
echo '# parent:' $p
- git/walk -fAMR $files | subst -g '^' '# '
+ /$cputype/bin/git/walk -fAMR $files | subst -g '^' '# '
echo '#'
echo '# Commit message:'
}
- giteditor=`{git/conf core.editor}
+ giteditor=`{/$cputype/bin/git/conf core.editor}
if(~ $#editor 0)
editor=$giteditor
if(~ $#editor 0)
@@ -80,7 +80,7 @@
if not if(~ $initial true)
parents=()
if not
- parents=`{git/query $branch}
+ parents=`{/$cputype/bin/git/query $branch}
}
fn commit{
@@ -87,7 +87,7 @@
msg=`"{cat $msgfile}
if(! ~ $#parents 0)
pflags='-p'^$parents
- hash=`{git/save -n $"name -e $"email -m $"msg $pflags $files || die $status}
+ hash=`{/$cputype/bin/git/save -n $"name -e $"email -m $"msg $pflags $files || die $status}
rm -f .git/index9/merge-parents
}
@@ -125,7 +125,7 @@
if(~ $#msg 1)
echo $msg >$msgfile.tmp
-files=`{git/walk -c `{cleanname $gitrel/$*}}
+files=`{/$cputype/bin/git/walk -c `{cleanname $gitrel/$*}}
if(~ $status '' || ~ $#files 0 && ! test -f .git/index9/merge-parents)
die 'nothing to commit' $status
@{
--- a/common.rc
+++ b/common.rc
@@ -31,7 +31,7 @@
}
fn gitup{
- gitroot=`{git/conf -r >[2]/dev/null}
+ gitroot=`{/$cputype/bin/git/conf -r >[2]/dev/null}
if(~ $#gitroot 0)
die 'not a git repository'
gitrel=`{pwd | subst '^'$"gitroot'/?'}
@@ -44,7 +44,7 @@
if(! grep -s '^repo '$gitroot'$' /mnt/git/ctl >[2]/dev/null)
startfs=true
if(~ $#startfs 1)
- git/fs
+ /$cputype/bin/git/fs
if not
status=''
}
--- a/diff
+++ b/diff
@@ -12,14 +12,14 @@
files=()
if(! ~ $#* 0)
files=`{cleanname $gitrel/$*}
-branch=`{git/query -p $commit}
+branch=`{/$cputype/bin/git/query -p $commit}
if(~ $summarize 1){
- git/walk -fMAR $files
+ /$cputype/bin/git/walk -fMAR $files
exit
}
-dirty=`$nl{git/walk -c -fRMA $files}
+dirty=`$nl{/$cputype/bin/git/walk -c -fRMA $files}
if(! ~ $commit HEAD)
- dirty=($dirty `$nl{git/query -c $commit HEAD | subst '^..'})
+ dirty=($dirty `$nl{/$cputype/bin/git/query -c $commit HEAD | subst '^..'})
for(f in $dirty){
orig=$branch/tree/$f
if(! test -f $orig)
--- a/export
+++ b/export
@@ -19,13 +19,13 @@
q=$*
if(~ $#q 0)
q=HEAD
-commits=`{git/query $q || die $status}
+commits=`{/$cputype/bin/git/query $q || die $status}
n=1
m=$#commits
mntgen /mnt/scratch
for(c in $commits){
- cp=`{git/query -p $c}
- pp=`{git/query -p $c'^'}
+ cp=`{/$cputype/bin/git/query -p $c}
+ pp=`{/$cputype/bin/git/query -p $c'^'}
@{
rfork n
--- a/import
+++ b/import
@@ -8,12 +8,12 @@
}
fn apply @{
- git/fs
+ /$cputype/bin/git/fs
email=''
name=''
msg=''
- parents='-p'^`{git/query HEAD}
- branch=`{git/branch}
+ parents='-p'^`{/$cputype/bin/git/query HEAD}
+ branch=`{/$cputypeb/in/git/branch}
if(test -e /mnt/git/branch/$branch/tree)
refpath=.git/refs/$branch
if not if(test -e /mnt/git/object/$branch/tree)
@@ -77,12 +77,12 @@
files=`$nl{ape/patch -Ep1 < $diffpath | sed ''s/^patching file `(.*)''''/\1/''}
for(f in $files){
if(test -e $f)
- git/add $f
+ /$cputype/bin/git/add $f
if not
- git/add -r $f
+ /$cputype/bin/git/add -r $f
}
- git/walk -fRMA $files
- hash=`{git/save -n $name -e $email -m $msg -d $date $parents $files}
+ /$cputype/bin/git/walk -fRMA $files
+ hash=`{/$cputype/bin/git/save -n $name -e $email -m $msg -d $date $parents $files}
echo $hash > $refpath
'
}
--- a/log
+++ b/log
@@ -9,11 +9,11 @@
base=/mnt/git/object/
if(~ $#branch 0)
- branch=`{git/branch}
+ branch=`{/$cputype/bin/git/branch}
if(~ $#expr 0)
- commits=`{git/query $branch}
+ commits=`{/$cputype/bin/git/query $branch}
if not
- commits=`{git/query $expr}
+ commits=`{/$cputype/bin/git/query $expr}
files=()
if(! ~ $#* 0)
@@ -24,7 +24,7 @@
show=()
c=$commits(1)
if(! ~ $#files 0){
- ncomm=`{comm -12 /env/files <{git/query -c $c~ $c | subst '^..' | sort} | wc -l}
+ ncomm=`{comm -12 /env/files <{/$cputype/bin/git/query -c $c~ $c | subst '^..' | sort} | wc -l}
if(! ~ $ncomm 0)
show=true
}
--- a/merge
+++ b/merge
@@ -23,9 +23,9 @@
echo merge needed: $f
if(test -f $f)
- git/add $f
+ /$cputype/bin/git/add $f
if not
- git/rm $f
+ /$cputype/bin/git/rm $f
}
}
@@ -37,18 +37,18 @@
if(! ~ $#* 1)
exec aux/usage
-theirs=`{git/query $1}
-ours=`{git/query HEAD}
-base=`{git/query $theirs ^ ' ' ^ $ours ^ '@'}
+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(! git/walk -q)
+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/`{git/branch}
- git/revert .
+ echo $theirs > .git/refs/`{/$cputype/bin/git/branch}
+ /$cputype/bin/git/revert .
exit ''
}
echo $ours >> .git/index9/merge-parents
--- a/mkfile
+++ b/mkfile
@@ -17,6 +17,7 @@
branch\
clone\
commit\
+ compat\
diff\
export\
import\
--- a/pull
+++ b/pull
@@ -10,7 +10,7 @@
bflag=()
if(! ~ $branch '')
bflag=(-b $branch)
- {git/fetch $bflag -u $upstream $url >[2=3] || die $status} | awk '
+ {/$cputype/bin/git/fetch $bflag -u $upstream $url >[2=3] || die $status} | awk '
/^remote/{
if($2=="HEAD")
next
@@ -33,13 +33,13 @@
eval `''{aux/getflags $*} || exec aux/usage
if(~ $#branch 0)
- branch=refs/`{git/branch}
+ branch=refs/`{/$cputype/bin/git/branch}
if(~ $allbranch 1)
branch=''
if(~ $#upstream 0)
upstream=origin
-remote=`{git/conf 'remote "'$upstream'".url'}
+remote=`{/$cputype/bin/git/conf 'remote "'$upstream'".url'}
if(~ $#remote 0)
die 'no remote to pull from'
@@ -47,22 +47,22 @@
if (~ $fetchonly 1)
exit
-local=`{git/branch}
-remote=`{git/branch | subst '^(refs/)?heads' 'remotes/'$upstream}
+local=`{//$cputype/bin/git/branch}
+remote=`{/$cputype/bin/git/branch | subst '^(refs/)?heads' 'remotes/'$upstream}
# we have local commits, but the remote hasn't changed.
# in this case, we want to keep the local commits untouched.
-if(~ `{git/query HEAD $remote @} `{git/query $remote}){
+if(~ `{/$cputype/bin/git/query HEAD $remote @} `{/$cputype/bin/git/query $remote}){
echo 'up to date' >[1=2]
exit
}
# The remote repository and our HEAD have diverged: we
# need to merge.
-if(! ~ `{git/query HEAD $remote @} `{git/query HEAD}){
+if(! ~ `{/$cputype/bin/git/query HEAD $remote @} `{/$cputype/bin/git/query HEAD}){
>[1=2]{
- echo ours: `{git/query HEAD}
- echo theirs: `{git/query $remote}
- echo common: `{git/query HEAD $remote @}
+ echo ours: `{/$cputype/bin/git/query HEAD}
+ echo theirs: `{/$cputype/bin/git/query $remote}
+ echo common: `{/$cputype/bin/git/query HEAD $remote @}
echo git/merge $remote
}
exit diverged
@@ -70,8 +70,8 @@
# The remote is directly ahead of the local, and we have
# no local commits that need merging.
if(~ $quiet 0)
- git/log -s -e $local'..'$remote >[1=2]
+ /$cputype/bin/git/log -s -e $local'..'$remote >[1=2]
echo
-echo $remote':' `{git/query $local} '=>' `{git/query $remote} >[1=2]
-git/branch -n -b $remote $local
+echo $remote':' `{/$cputype/bin/git/query $local} '=>' `{/$cputype/bin/git/query $remote} >[1=2]
+/$cputype/bin/git/branch -n -b $remote $local
exit ''
--- a/push
+++ b/push
@@ -13,7 +13,7 @@
if(~ $pushall 1)
branch=`$nl{cd .git/refs/heads && walk -f}
if(~ $#branch 0)
- branch=`{git/branch}
+ branch=`{/$cputype/bin/git/branch}
if(~ $#branch 0)
die 'no branches'
if(~ $force 1)
@@ -24,13 +24,13 @@
if(~ $#upstream 0)
upstream=origin
-remote=`{git/conf 'remote "'$upstream'".url'}
+remote=`{/$cputype/bin/git/conf 'remote "'$upstream'".url'}
if(~ $#remote 0)
remote=$upstream
branch=-b^$branch
if(! ~ $#remove 0)
remove=-r^$remove
-updates=`$nl{git/send $debug $force $branch $remove $remote || die $status}
+updates=`$nl{/$cputype/bin/git/send $debug $force $branch $remove $remote || die $status}
for(ln in $updates){
u=`{echo $ln}
refpath=`{echo $u(2) | subst '^refs/heads/' '.git/refs/remotes/'$upstream'/'}
--- a/rm
+++ b/rm
@@ -1,3 +1,3 @@
#!/bin/rc -e
-exec git/add -r $*
+exec /$cputype/bin/git/add -r $*