Plan 9 from Bell Labs’s /usr/web/sources/contrib/yk/root/rc/bin/git/push

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


#!/bin/rc -e
rfork en
. /rc/bin/git/defs

gitup

flagfmt='a,f,d,b branch,r remove,u upstream' args=''
ifs=() eval `{aux/getflags $*} || exec aux/usage
pushall=$flaga branch=$flagb force=$flagf debug=$flagd
remove=$flagr upstream=$flagu
if(! ~ $#* 0)
	exec aux/usage

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

if(~ $#upstream 0)
	upstream=origin

ifs=$nl {
	remotes=`{git/conf -a 'remote "'$upstream'".url'}
}
if(~ $#remotes 0)
	remotes=$upstream
branch=-b^$branch
if(! ~ $#remove 0)
	remove=-r^$remove
for(remote in $remotes){
	ifs=$nl {
		updates=`{git/send $debug $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 ''

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to webmaster@9p.io.