ref: f8bf36dc99975ea582975096522f6acece3e4bf6
dir: /push/
#!/bin/rc rfork en nl=' ' if(! cd `{git/conf -r}) exit 'not in git repository' git/fs fn usage { echo usage: $0 '[-a] [-u upstream] [-b branch] [-r rmbranch] -a: push all -u upstream: push to repo "upstream" (default: origin) -b branch: push branch "branch" (default: current branch)' >[1=2] exit usage } remote=() sendall='' remove=() force=() upstream='origin' branch=`{awk '$1=="branch"{print $2}' < /mnt/git/ctl} while(~ $1 -*){ switch($1){ case -u shift upstream=$1 case -a sendall=true case -b shift branch=$1 case -r shift remove=(-r$1 $remove); case -f force=-f case * usage } shift } if(! ~ $#* 0) usage if(~ $#remote 0) remote=`{git/conf 'remote "'$upstream'".url'} if(~ $#remote 0) remote=$upstream if(~ $#remote 0){ echo 'no idea where to push' exit upstream } if(~ $sendall '') updates=`$nl{git/send $force -b $branch $remove $remote} if not updates=`$nl{git/send $force $remove -a $remote} x=$status if(! ~ $x '') exit $x for(ln in $updates){ u=`{echo $ln} refpath=`{echo $u(2) | sed 's@^refs/heads/@.git/refs/remotes/@g'} switch($u(1)){ case update; echo $u(4) > $refpath echo $u(2)^':' $u(3) '=>' $u(4) case delete; echo $u(2)^': removed' rm -f $refpath case uptodate; echo $u(2)^': up to date' } }