shithub: git9

Download patch

ref: 7cea6be90dc64c7037bc25ccb5d3473e3bd261d7
parent: 298786ef6363913eef5fb30827103831fc4881ea
author: Ori Bernstein <ori@eigenstate.org>
date: Sat Dec 7 01:52:56 EST 2019

walk args to git/add: allows adding directories.

--- a/add
+++ b/add
@@ -27,12 +27,14 @@
 rel=`{sed 's@^'$gitroot'/*@@' <{echo $dir}}
 if(~ $#rel 0)
 	rel=''
-for(f in $*){
-	addpath=.git/index9/$add/$rel/$f
-	delpath=.git/index9/$del/$rel/$f
-	mkdir -p `{basename -d $addpath}
-	mkdir -p `{basename -d $delpath}
-	if(! test -e $addpath)
-		walk -eq $f > $addpath
-	rm -f $delpath
+for(f in `{walk -f $*}){
+	if(! ~ `{cleanname $f} .git/*){
+		addpath=.git/index9/$add/$rel/$f
+		delpath=.git/index9/$del/$rel/$f
+		mkdir -p `{basename -d $addpath}
+		mkdir -p `{basename -d $delpath}
+		if(! test -e $addpath)
+			walk -eq $f > $addpath
+		rm -f $delpath
+	}
 }
--- a/save.c
+++ b/save.c
@@ -323,10 +323,8 @@
 	Object *t, *c;
 	Hash h;
 
-	if(resolveref(&h, "HEAD") == -1){
-		fprint(2, "empty HEAD ref\n");
+	if(resolveref(&h, "HEAD") == -1)
 		return emptydir();
-	}
 	if((c = readobject(h)) == nil || c->type != GCommit)
 		sysfatal("could not read HEAD %H", h);
 	if((t = readobject(c->commit->tree)) == nil)