shithub: git9

ref: 29bce68c99b7d73cf9b7956a797e8f2e737d8684
dir: /push/

View raw version
#!/bin/rc -e
rfork en
. /sys/lib/git/common.rc

gitup

flagfmt='a:pushall, b:branch branch, f:force,
         r:remove remove, u:upstream upstream' args=''
eval `''{aux/getflags $*} || exec aux/usage
if(! ~ $#* 0)
	exec aux/usage

if(~ $pushall 1)
	branch=`$nl{cd .git/refs/heads && walk -f}
if(~ $#branch 0)
	branch=`{git/branch}
if(~ $#branch 0)
	die 'no branches'
if(~ $force 1)
	force=-f

if(~ $#upstream 0)
	upstream=origin

remote=`{git/conf 'remote "'$upstream'".url'}
if(~ $#remote 0)
	remote=$upstream
branch=-b^$branch
if(! ~ $#remove 0)
	remove=-r^$remove
updates=`$nl{git/send $force $branch $remove $remote || die $status}
for(ln in $updates){
	u=`{echo $ln}
	refpath=`{echo $u(2) | subst '^refs/heads/' '.git/refs/remotes/'$upstream'/'}
	switch($u(1)){
	case update;
		mkdir -p `{basename -d $refpath}
		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'
	}
}
exit ''