shithub: git9

ref: 666f62f08c94f8928c04f37fa2849bea4fba8f1d
dir: /init/

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

flagfmt='b:bare, u:upstream upstream'; args='name'
eval `''{aux/getflags $*} || exec aux/usage

dir=$1
if(~ $#dir 0)
	exec aux/usage
dotgit=$dir/.git
if(~ $#bare 1)
	dotgit=$dir
name=`{basename `{cleanname -d `{pwd} $dir}}
if(~ $#upstream 0){
	upstream=`{git/conf 'defaults "origin".baseurl'}
	if(! ~ $#upstream 0)
		upstream=$upstream/$name
}

if(test -e $dotgit)
	die $dotgit already exists

mkdir -p $dotgit/refs/^(heads remotes)
dircp /sys/lib/git/template $dotgit
>>$dotgit/config {
	if(! ~ $#upstream 0){
		echo '[remote "origin"]'
		echo '	url = '$upstream
	}
	echo '[branch "master"]'
	echo '	remote = origin'
	echo '	merge = refs/heads/master' 
}
exit ''