shithub: git9

Download patch

ref: 4f6509f5c6e075201c450862d32c0d76514b3658
parent: ad501293034d30f5ac8c65c44c5446c46b6fda8d
author: Ori Bernstein <ori@eigenstate.org>
date: Wed Oct 16 02:11:44 EDT 2019

Implement -i option for git/pull, show dates in log.

--- a/branch
+++ b/branch
@@ -66,7 +66,6 @@
 	candidates=(.git/refs/$base .git/refs/heads/$base .git/refs/remotes/$base .git/refs/remotes/$remotes/$base)
 	for(br in $candidates){
 		if(~ $#branched 0 && test -f $br){
-			echo $base '=>' $1
 			cp $br .git/$new
 			branched=true
 		}
--- a/fs.c
+++ b/fs.c
@@ -627,7 +627,7 @@
 static void
 gitread(Req *r)
 {
-	char buf[64], *e;
+	char buf[256], *e;
 	Gitaux *aux;
 	Object *o;
 	Qid *q;
@@ -664,7 +664,8 @@
 		readstr(r, buf);
 		break;
 	case Qcommitauthor:
-		readstr(r, o->commit->author);
+		snprint(buf, sizeof(buf), "%s\n", o->commit->author);
+		readstr(r, buf);
 		break;
 	case Qctl:
 		e = readctl(r);
--- a/log
+++ b/log
@@ -13,7 +13,8 @@
 
 base=/mnt/git/object/
 git/fs
-branch=master
+branch=`{git/branch}
+query=()
 
 while(~ $1 -* && ! ~ $1 --){
 	switch($1){
@@ -20,6 +21,9 @@
 	case -b
 		branch=$2
 		shift
+	case -q
+		query=$2
+		shift
 	case *
 		usage
 	}
@@ -27,7 +31,10 @@
 }
 if(~ $1 --)
 	shift
-commits=`{git/query $branch}
+if(~ $#query 0)
+	commits=`{git/query $branch}
+if not
+	commits=`{git/query $query}
 files=()
 if(! ~ $#* 0)
 	files=`$nl{walk -f $*}
@@ -40,13 +47,16 @@
 	c=$commits(1)
 	if(! ~ $#files 0)
 		nids=`{sha1sum $base/$commits(1)^/tree/$files | awk '{print $1}' >[2]/dev/null}
-
-	commits=($commits(2-) `{cat $base/$c/parent >[2]/dev/null})
+		commits=$commits(2-)
+		if(~ $#query 0)
+			commits=($commits `{cat $base/$c/parent >[2]/dev/null})
 	if(! ~ $#commits 0)
 		commits=`$nl{walk -emp -n0 $base^$commits | sort -rn | uniq | awk -F/ '{print $NF}'}
 
 	if(~ $#files 0 || ! ~ $"ids $"nids || ~ $#commits 0){
-		echo 'Hash:	'^`''{cat $base/$c/hash}^'Author:	'^`''{cat $base/$c/author}
+		echo -n 'Hash:	'`''{cat $base/$c/hash}
+		echo -n 'Author:	'`''{cat $base/$c/author}
+		echo -n 'Date:	'`''{date `{mtime $base/$c/msg | awk '{print $1}'}}
 		sed 's/^/	/g' $base/$c/msg
 		echo
 	}
--- a/pull
+++ b/pull
@@ -41,6 +41,7 @@
 
 branch=`{awk '$1=="branch"{print $2}' < /mnt/git/ctl}
 remote=()
+incoming=()
 checkout='true'
 upstream=origin
 
@@ -61,6 +62,8 @@
 		shift
 	case -f
 		checkout=()
+	case -i
+		incoming=true
 	case *
 		usage
 	}
@@ -98,4 +101,7 @@
 
 # The remote is directly ahead of the local, and we have
 # no local commits that need merging.
+echo $local':' `{git/query $local} '=>' `{git/query $remote}  >[1=2]
+if(! ~ $#incoming 0)
+	git/log -q $local'..'$remote
 git/branch -u -b $remote $local
--- a/ref.c
+++ b/ref.c
@@ -85,7 +85,7 @@
 	int n;
 
 	p = ev->p;
-	for(e = p; isword(*e); e++)
+	for(e = p; isword(*e) && strncmp(e, "..", 2) != 0; e++)
 		/* nothing */;
 	/* 1 for nul terminator */
 	n = e - p + 1;
@@ -282,7 +282,8 @@
 		else if(oshas(&skip, p))
 			if((nall = unwind(ev, all, idx, nall, &p, &skip, 0)) == -1)
 				break;
-
+		if(p->commit->nparent == 0)
+			break;
 		if((p = readobject(p->commit->parent[idx[nall]])) == nil)
 			sysfatal("bad commit %H", p->commit->parent[idx[nall]]);
 		nall++;