code: plan9front

Download patch

ref: 2810cc5d0c01b06e678b50995edb724c739b8eed
parent: 67970c4c6bdaed7fb0b6e6a22f77f23a7acd2f0a
author: glenda <glenda@jasnah>
date: Mon Jul 3 19:50:36 EDT 2023

git/walk: fix usage on new repo

--- a/sys/src/cmd/git/walk.c
+++ b/sys/src/cmd/git/walk.c
@@ -30,8 +30,7 @@
 int quiet;
 int useindex;
 int printflg;
-char *base = "HEAD";
-char *bdir;
+char *bdir = ".git/fs/HEAD/tree";
 char *rstr = "R ";
 char *tstr = "T ";
 char *mstr = "M ";
@@ -218,7 +217,7 @@
 void
 main(int argc, char **argv)
 {
-	char *rpath, *tpath, *bpath, buf[8], repo[512];
+	char *rpath, *tpath, *bpath, *base, buf[8], repo[512];
 	char *p, *e;
 	int i, dirty;
 	Wres r;
@@ -250,6 +249,9 @@
 	case 'b':
 		useindex = 0;
 		base = EARGF(usage());
+		if(resolveref(&h, base) == -1)
+			sysfatal("no such ref '%s'", base);
+		bdir = smprint(".git/fs/object/%H/tree", h);
 		break;
 	default:
 		usage();
@@ -262,9 +264,6 @@
 		sysfatal("chdir: %r");
 	if(access(".git/fs/ctl", AEXIST) != 0)
 		sysfatal("no running git/fs");
-	if(resolveref(&h, base) == -1)
-		sysfatal("no such ref '%s'", base);
-	bdir = smprint(".git/fs/object/%H/tree", h);
 	dirty = 0;
 	memset(&r, 0, sizeof(r));
 	if(printflg == 0)