ref: 32d0c36db869b89a8d7d2669cc3d05a72e8025ce
parent: 8d7ff33feb7f018ea331edca7918118da453f999
author: Ori Bernstein <ori@eigenstate.org>
date: Fri Sep 4 18:29:56 EDT 2020
scripts: revert 777e9c6d56ed9eaeb28196b3b6da77a34139f892 With the change in mechanism for git/compat, we don't need to use the full path to git binaries, and the full path is a bit ugly. Let's roll it back.
--- a/branch
+++ b/branch
@@ -30,18 +30,18 @@
new=refs/heads/$branch
if (~ $#baseref 1)
- base=`{/$cputype/bin/git/query $baseref} || exit 'bad base'+ base=`{git/query $baseref} || exit 'bad base'if not if(test -e .git/$new)
- base=`{/$cputype/bin/git/query $new}+ base=`{git/query $new}if not
- base=`{/$cputype/bin/git/query HEAD}+ base=`{git/query HEAD}-modified=`$nl{/$cputype/bin/git/query -c HEAD $base | grep '^[^-]' | subst '^..'}-deleted=`$nl{/$cputype/bin/git/query -c HEAD $base | grep '^-' | subst '^..'}+modified=`$nl{git/query -c HEAD $base | grep '^[^-]' | subst '^..'}+deleted=`$nl{git/query -c HEAD $base | grep '^-' | subst '^..'} if(! ~ $#modified 0 || ! ~ $#deleted 0){- if(! /$cputype/bin/git/walk -q $modified $deleted){- /$cputype/bin/git/walk -fRMA $modified $deleted
+ if(! git/walk -q $modified $deleted){+ 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=`{/$cputype/bin/git/query $base} || die 'branch does not exist:' $base+commit=`{git/query $base} || die 'branch does not exist:' $baseecho updating $new to $commit
echo $commit > .git/$new
@@ -65,7 +65,7 @@
exit
if(! ~ $#modified 0){- basedir=`{/$cputype/bin/git/query -p $base}+ basedir=`{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/*'
}
- {/$cputype/bin/git/fetch $remote >[2=3] | awk '+ {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=`{/$cputype/bin/git/branch}+ lbranch=`{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
- /$cputype/bin/git/fs
+ 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=`{/$cputype/bin/git/conf user.name}- email=`{/$cputype/bin/git/conf user.email}+ name=`{git/conf user.name}+ email=`{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=`{/$cputype/bin/git/branch}+ branch=`{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
- /$cputype/bin/git/walk -fAMR $files | subst -g '^' '# '
+ git/walk -fAMR $files | subst -g '^' '# '
echo '#'
echo '# Commit message:'
}
- giteditor=`{/$cputype/bin/git/conf core.editor}+ giteditor=`{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=`{/$cputype/bin/git/query $branch}+ parents=`{git/query $branch}}
fn commit{@@ -87,7 +87,7 @@
msg=`"{cat $msgfile}if(! ~ $#parents 0)
pflags='-p'^$parents
- hash=`{/$cputype/bin/git/save -n $"name -e $"email -m $"msg $pflags $files || die $status}+ hash=`{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=`{/$cputype/bin/git/walk -c `{cleanname $gitrel/$*}}+files=`{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=`{/$cputype/bin/git/conf -r >[2]/dev/null}+ gitroot=`{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)
- /$cputype/bin/git/fs
+ git/fs
if not
status=''
}
--- a/compat
+++ b/compat
@@ -20,7 +20,7 @@
shift
}
ls >[1=2]
- /$cputype/bin/git/init $opts $args
+ git/init $opts $args
}
fn cmd_clone{@@ -39,15 +39,15 @@
}
shift
}
- /$cputype/bin/git/clone $opts $args
+ git/clone $opts $args
if(~ $#branch 1)
- /$cputype/bin/git/branch -n -b $1 origin/$1
+ git/branch -n -b $1 origin/$1
}
fn cmd_pull{if(~ $1 -*)
die unknown options for pull $*
- /$cputype/bin/git/pull
+ git/pull
}
fn cmd_fetch{@@ -67,7 +67,7 @@
}
shift
}
- /$cputype/bin/git/pull -f $opts
+ git/pull -f $opts
}
@@ -76,7 +76,7 @@
die unknown command pull $*
if(~ $#* 0)
die git checkout branch
- /$cputype/bin/git/branch $b
+ git/branch $b
}
fn rev-parse{--- a/diff
+++ b/diff
@@ -12,14 +12,14 @@
files=()
if(! ~ $#* 0)
files=`{cleanname $gitrel/$*}-branch=`{/$cputype/bin/git/query -p $commit}+branch=`{git/query -p $commit} if(~ $summarize 1){- /$cputype/bin/git/walk -fMAR $files
+ git/walk -fMAR $files
exit
}
-dirty=`$nl{/$cputype/bin/git/walk -c -fRMA $files}+dirty=`$nl{git/walk -c -fRMA $files}if(! ~ $commit HEAD)
- dirty=($dirty `$nl{/$cputype/bin/git/query -c $commit HEAD | subst '^..'})+ dirty=($dirty `$nl{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=`{/$cputype/bin/git/query $q || die $status}+commits=`{git/query $q || die $status}n=1
m=$#commits
mntgen /mnt/scratch
for(c in $commits){- cp=`{/$cputype/bin/git/query -p $c}- pp=`{/$cputype/bin/git/query -p $c'^'}+ cp=`{git/query -p $c}+ pp=`{git/query -p $c'^'} @{rfork n
--- a/import
+++ b/import
@@ -8,12 +8,12 @@
}
fn apply @{- /$cputype/bin/git/fs
+ git/fs
email=''
name=''
msg=''
- parents='-p'^`{/$cputype/bin/git/query HEAD}- branch=`{/$cputypeb/in/git/branch}+ parents='-p'^`{git/query HEAD}+ branch=`{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)
- /$cputype/bin/git/add $f
+ git/add $f
if not
- /$cputype/bin/git/add -r $f
+ git/add -r $f
}
- /$cputype/bin/git/walk -fRMA $files
- hash=`{/$cputype/bin/git/save -n $name -e $email -m $msg -d $date $parents $files}+ git/walk -fRMA $files
+ hash=`{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=`{/$cputype/bin/git/branch}+ branch=`{git/branch}if(~ $#expr 0)
- commits=`{/$cputype/bin/git/query $branch}+ commits=`{git/query $branch}if not
- commits=`{/$cputype/bin/git/query $expr}+ commits=`{git/query $expr}files=()
if(! ~ $#* 0)
@@ -24,7 +24,7 @@
show=()
c=$commits(1)
if(! ~ $#files 0){- ncomm=`{comm -12 /env/files <{/$cputype/bin/git/query -c $c~ $c | subst '^..' | sort} | wc -l}+ ncomm=`{comm -12 /env/files <{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)
- /$cputype/bin/git/add $f
+ git/add $f
if not
- /$cputype/bin/git/rm $f
+ git/rm $f
}
}
@@ -37,18 +37,18 @@
if(! ~ $#* 1)
exec aux/usage
-theirs=`{/$cputytpe/bin/git/query $1}-ours=`{/$cputype/bin/git/query HEAD}-base=`{/$cputype/bin/git/query $theirs ^ ' ' ^ $ours ^ '@'}+theirs=`{git/query $1}+ours=`{git/query HEAD}+base=`{git/query $theirs ^ ' ' ^ $ours ^ '@'}if(~ $base $theirs)
die 'nothing to merge, doofus'
-if(! /$cputype/bin/git/walk -q)
+if(! 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 .
+ echo $theirs > .git/refs/`{git/branch}+ git/revert .
exit ''
}
echo $ours >> .git/index9/merge-parents
--- a/mkfile
+++ b/mkfile
@@ -17,7 +17,6 @@
branch\
clone\
commit\
- compat\
diff\
export\
import\
--- a/pull
+++ b/pull
@@ -10,7 +10,7 @@
bflag=()
if(! ~ $branch '')
bflag=(-b $branch)
- {/$cputype/bin/git/fetch $bflag -u $upstream $url >[2=3] || die $status} | awk '+ {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/usageif(~ $#branch 0)
- branch=refs/`{/$cputype/bin/git/branch}+ branch=refs/`{git/branch}if(~ $allbranch 1)
branch=''
if(~ $#upstream 0)
upstream=origin
-remote=`{/$cputype/bin/git/conf 'remote "'$upstream'".url'}+remote=`{git/conf 'remote "'$upstream'".url'}if(~ $#remote 0)
die 'no remote to pull from'
@@ -47,22 +47,22 @@
if (~ $fetchonly 1)
exit
-local=`{//$cputype/bin/git/branch}-remote=`{/$cputype/bin/git/branch | subst '^(refs/)?heads' 'remotes/'$upstream}+local=`{git/branch}+remote=`{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(~ `{/$cputype/bin/git/query HEAD $remote @} `{/$cputype/bin/git/query $remote}){+if(~ `{git/query HEAD $remote @} `{git/query $remote}){echo 'up to date' >[1=2]
exit
}
# The remote repository and our HEAD have diverged: we
# need to merge.
-if(! ~ `{/$cputype/bin/git/query HEAD $remote @} `{/$cputype/bin/git/query HEAD}){+if(! ~ `{git/query HEAD $remote @} `{git/query HEAD}){ >[1=2]{- echo ours: `{/$cputype/bin/git/query HEAD}- echo theirs: `{/$cputype/bin/git/query $remote}- echo common: `{/$cputype/bin/git/query HEAD $remote @}+ echo ours: `{git/query HEAD}+ echo theirs: `{git/query $remote}+ echo common: `{git/query HEAD $remote @}echo git/merge $remote
}
exit diverged
@@ -69,9 +69,9 @@
}
# The remote is directly ahead of the local, and we have
# no local commits that need merging.
-if(~ $quiet 0)
- /$cputype/bin/git/log -s -e $local'..'$remote >[1=2]
+if(~ $#quiet 0)
+ git/log -s -e $local'..'$remote >[1=2]
echo
-echo $remote':' `{/$cputype/bin/git/query $local} '=>' `{/$cputype/bin/git/query $remote} >[1=2]-/$cputype/bin/git/branch -n -b $remote $local
+echo $remote':' `{git/query $local} '=>' `{git/query $remote} >[1=2]+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=`{/$cputype/bin/git/branch}+ branch=`{git/branch}if(~ $#branch 0)
die 'no branches'
if(~ $force 1)
@@ -24,13 +24,13 @@
if(~ $#upstream 0)
upstream=origin
-remote=`{/$cputype/bin/git/conf 'remote "'$upstream'".url'}+remote=`{git/conf 'remote "'$upstream'".url'}if(~ $#remote 0)
remote=$upstream
branch=-b^$branch
if(! ~ $#remove 0)
remove=-r^$remove
-updates=`$nl{/$cputype/bin/git/send $debug $force $branch $remove $remote || die $status}+updates=`$nl{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 /$cputype/bin/git/add -r $*
+exec git/add -r $*
--
⑨