Skip to content

Commit

Permalink
scripts: revert 777e9c6
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
oridb committed Sep 4, 2020
1 parent 8d7ff33 commit 32d0c36
Show file tree
Hide file tree
Showing 14 changed files with 72 additions and 73 deletions.
18 changes: 9 additions & 9 deletions branch
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,18 @@ if not
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'
}
}
Expand All @@ -56,7 +56,7 @@ if(~ $#newbr 0){
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:' $base
echo updating $new to $commit
echo $commit > .git/$new
Expand All @@ -65,7 +65,7 @@ if(! ~ $#stay 0)
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
Expand Down
6 changes: 3 additions & 3 deletions clone
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ fn clone{
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
Expand Down Expand Up @@ -64,12 +64,12 @@ fn clone{
'} |[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'/*'}){
Expand Down
16 changes: 8 additions & 8 deletions commit
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ rfork ne
. /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}
Expand All @@ -18,7 +18,7 @@ fn whoami{
}

fn findbranch{
branch=`{/$cputype/bin/git/branch}
branch=`{git/branch}
if(test -e /mnt/git/branch/$branch/tree){
refpath=.git/refs/$branch
initial=false
Expand Down Expand Up @@ -58,11 +58,11 @@ fn editmsg{
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)
Expand All @@ -80,14 +80,14 @@ fn parents{
if not if(~ $initial true)
parents=()
if not
parents=`{/$cputype/bin/git/query $branch}
parents=`{git/query $branch}
}
fn commit{
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
}
Expand Down Expand Up @@ -125,7 +125,7 @@ msgfile=/tmp/git-msg.$pid
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
@{
Expand Down
4 changes: 2 additions & 2 deletions common.rc
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ fn subst{
}

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'/?'}
Expand All @@ -44,7 +44,7 @@ fn gitup{
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=''
}
12 changes: 6 additions & 6 deletions compat
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ fn cmd_init{
shift
}
ls >[1=2]
/$cputype/bin/git/init $opts $args
git/init $opts $args
}

fn cmd_clone{
Expand All @@ -39,15 +39,15 @@ fn cmd_clone{
}
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{
Expand All @@ -67,7 +67,7 @@ fn cmd_fetch{
}
shift
}
/$cputype/bin/git/pull -f $opts
git/pull -f $opts
}


Expand All @@ -76,7 +76,7 @@ fn cmd_checkout{
die unknown command pull $*
if(~ $#* 0)
die git checkout branch
/$cputype/bin/git/branch $b
git/branch $b
}

fn rev-parse{
Expand Down
8 changes: 4 additions & 4 deletions diff
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ if(~ $#commit 0)
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)
Expand Down
6 changes: 3 additions & 3 deletions export
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ if(~ $#patchdir 1 && ! test -d $patchdir)
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
Expand Down
14 changes: 7 additions & 7 deletions import
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ fn sigexit {
}

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)
Expand Down Expand Up @@ -77,12 +77,12 @@ fn apply @{
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
'
}
Expand Down
8 changes: 4 additions & 4 deletions log
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ eval `''{aux/getflags $*} || exec aux/usage
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)
Expand All @@ -24,7 +24,7 @@ while(! ~ $#commits 0){
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
}
Expand Down
16 changes: 8 additions & 8 deletions merge
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ fn merge{
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
}
}
Expand All @@ -37,18 +37,18 @@ 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 ^ '@'}
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
Expand Down
1 change: 0 additions & 1 deletion mkfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ RC=\
branch\
clone\
commit\
compat\
diff\
export\
import\
Expand Down
28 changes: 14 additions & 14 deletions pull
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ fn update{
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
Expand All @@ -33,45 +33,45 @@ args=''
eval `''{aux/getflags $*} || exec aux/usage
if(~ $#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'
update $branch $upstream $remote
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
}
# 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 ''
Loading

0 comments on commit 32d0c36

Please sign in to comment.