shithub: git9

Download patch

ref: 44a6f2799e78fb097b5d99914dfe83cc1436b2a7
parent: a93b357580f352497c5414254341874ff0e9022d
author: Ori Bernstein <ori@eigenstate.org>
date: Sat Jan 16 15:14:12 EST 2021

git/init: change default branch, remove template

The stuff in the template directory is mostly
unused by git9, so we may as well get rid of it.

While we're here, remove support for creating
bare repos, since none of the rest of our stuff
supports it, and having an extra '.git/' in an
empty dir isn't worth the trouble.

Also while we're here, change the default branch
to 'front': it's more playful than 'main', and
avoids debates about the default name.

diff: cannot open a/template/info//null: file does not exist: 'a/template/info//null' diff: cannot open a/template//null: file does not exist: 'a/template//null'
--- a/init
+++ b/init
@@ -2,15 +2,16 @@
 rfork ne
 . /sys/lib/git/common.rc
 
-flagfmt='b:bare, u:upstream upstream'; args='name'
+flagfmt='u:upstream upstream,b:branch branch'; args='name'
 eval `''{aux/getflags $*} || exec aux/usage
 
 dir=$1
 if(~ $#dir 0)
-	exec aux/usage
-dotgit=$dir/.git
-if(~ $#bare 1)
-	dotgit=$dir
+	dir=.
+if(~ $#branch 0)
+	branch=front
+if(test -e $dir/.git)
+	die $dir/.git already exists
 name=`{basename `{cleanname -d `{pwd} $dir}}
 if(~ $#upstream 0){
 	upstream=`{git/conf 'defaults "origin".baseurl'}
@@ -18,18 +19,20 @@
 		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 {
+mkdir -p $dir/.git/refs/^(heads remotes)
+>$dir/.git/config {
+	echo '[core]'
+	echo '	repositoryformatversion = p9.0'
 	if(! ~ $#upstream 0){
 		echo '[remote "origin"]'
 		echo '	url = '$upstream
 	}
-	echo '[branch "master"]'
+	echo '[branch "'$branch'"]'
 	echo '	remote = origin'
-	echo '	merge = refs/heads/master' 
 }
+
+>$dir/.git/HEAD {
+	echo ref: refs/heads/$branch
+}
+
 exit ''
--- a/mkfile
+++ b/mkfile
@@ -54,7 +54,6 @@
 	cp git.1.man /sys/man/1/git
 	cp gitfs.4.man /sys/man/4/gitfs
 	cp common.rc /sys/lib/git/common.rc
-	mk $MKFLAGS /sys/lib/git/template
 
 uninstall:V:
 	rm -rf $BIN /sys/lib/git /sys/man/1/git /sys/man/4/gitfs
@@ -62,7 +61,3 @@
 %.rcinstall:V:
 	cp $stem $BIN/$stem
 	chmod +x $BIN/$stem
-
-/sys/lib/git/template: template
-	mkdir -p /sys/lib/git/template
-	dircp template /sys/lib/git/template
--- a/template/HEAD
+++ /dev/null
@@ -1,1 +1,0 @@
-ref: refs/heads/master
--- a/template/config
+++ /dev/null
@@ -1,5 +1,0 @@
-[core]
-	repositoryformatversion = 0
-	filemode = true
-	bare = false
-	logallrefupdates = true
--- a/template/description
+++ /dev/null
@@ -1,1 +1,0 @@
-Unnamed repository; edit this file 'description' to name the repository.
--- a/template/info/exclude
+++ /dev/null
@@ -1,6 +1,0 @@
-# git ls-files --others --exclude-from=.git/info/exclude
-# Lines that start with '#' are comments.
-# For a project mostly in C, the following would be a good set of
-# exclude patterns (uncomment them if you want to use them):
-# *.[oa]
-# *~