diff options
author | Ori Bernstein <ori@eigenstate.org> | 2021-05-30 19:06:01 -0700 |
---|---|---|
committer | Ori Bernstein <ori@eigenstate.org> | 2021-05-30 19:06:01 -0700 |
commit | 31fc689ad948b897c459505479a08494120c344a (patch) | |
tree | 0e7a2940ad453ffe9bcf01327161f6f77278f14b | |
parent | 12e952e684d149628360b6fcdb583be86052f944 (diff) | |
download | plan9front-31fc689ad948b897c459505479a08494120c344a.tar.xz |
git/branch: reduce execs to sync working dir
We were execing a lot to copy the data -- do less of it.
-rwxr-xr-x | sys/src/cmd/git/branch | 26 |
1 files changed, 18 insertions, 8 deletions
diff --git a/sys/src/cmd/git/branch b/sys/src/cmd/git/branch index f2656f2fa..48e4f0d72 100755 --- a/sys/src/cmd/git/branch +++ b/sys/src/cmd/git/branch @@ -63,32 +63,42 @@ if(~ $new */*) echo $commit > .git/$new if(! ~ $#stay 0) exit - basedir=`{git/query -p $base} dirtypaths=() cleanpaths=($modified $deleted) -if(! ~ $#modified 0 || ! ~ $#deleted 0) +if(! ~ $#modified 0 || ! ~ $#deleted 0){ + echo WUT dirtypaths=`$nl{git/walk -cfRMA $modified $deleted} +} if(! ~ $#dirtypaths 0){ x=$nl^$cleanpaths y=$nl^$dirtypaths cleanpaths=`$nl{echo $"x$nl$"y | sort | uniq -u} } +if(! ~ $#cleanpaths 0) + cleandirs=`$nl{echo $nl^$cleanpaths | sed 's@/[^/]+/?$@@' | uniq} +if(! ~ $#cleandirs 0){ + mkdir -p $cleandirs + mkdir -p .git/index9/tracked/$cleandirs +} +echo clean: $#clean +echo dirty: $#dirty for(m in $cleanpaths){ - d=`{basename -d $m} - mkdir -p $d - mkdir -p .git/index9/tracked/$d # Modifications can turn a file into # a directory, or vice versa, so we # need to delete and copy the files # over. - a=`{test -f $m && echo file || echo dir} - b=`{test -f $basedir/tree/$m && echo file || echo dir} + a=dir + b=dir + if(test -f $m) + a=file + if(test -f $basedir/tree/$m) + b=file if(! ~ $a $b){ rm -rf $m rm -rf .git/index9/tracked/$m } - if(test -f $basedir/tree/$m){ + if(~ $b file){ cp $basedir/tree/$m $m walk -eq $m > .git/index9/tracked/$m } |