ref: f5805c3552dd00a6018f8440c1a4c8aa6755fd03
dir: /add/
#!/bin/rc -e rfork ne fn usage { echo usage: $0 '[-r] file ... -r: remove instead of adding' >[1=2] exit usage } add='tracked' del='removed' while(~ $1 -* && ! ~ $1 --){ switch($1){ case -r add='removed' del='tracked' case * usage } shift } if(~ $1 --) shift dir=`{pwd} base=`{git/conf -r} x=$status if(! ~ $x ''){ echo git/conf: $x `{pwd} >[1=2] exit $x } cd $base rel=`{sed 's@^'$base'/*@@' <{echo $dir}} if(~ $#rel 0) rel='' for(f in $*){ if(! test -f $base/$rel/$f){ echo 'could not add '$base/$rel/$f': does not exist' >[1=2] exit 'nofile' } addpath=.git/index9/$add/$rel/$f delpath=.git/index9/$del/$rel/$f mkdir -p `{basename -d $addpath} mkdir -p `{basename -d $delpath} touch $addpath rm -f $delpath }