shithub: git9

Download patch

ref: 544dbac25e2d7ba3165b8e5370dd9b700c5ba14f
parent: 666f62f08c94f8928c04f37fa2849bea4fba8f1d
author: Ori Bernstein <[email protected]>
date: Sat Nov 28 21:09:42 EST 2020

git/serve: report when a repo does not exist

We were erroring out on the server, but never sending
the error to the client. The client instead got an empty
pack file and assumed that it just got an empty repository.

--- a/serve.c
+++ b/serve.c
@@ -98,7 +98,7 @@
 	while(1){
 		if((n = readpkt(c, pkt, sizeof(pkt))) == -1)
 			goto error;
-		if(strncmp(pkt, "done") == 0)
+		if(strncmp(pkt, "done", 4) == 0)
 			break;
 		if(n == 0){
 			if(!acked && fmtpkt(c, "NAK") == -1)
@@ -499,8 +499,10 @@
 	cleanname(repo);
 	if(strncmp(repo, "../", 3) == 0)
 		sysfatal("invalid path %s\n", repo);
-	if(bind(repo, "/", MREPL) == -1)
+	if(bind(repo, "/", MREPL) == -1){
+		fmtpkt(&c, "ERR no repo %r\n");
 		sysfatal("enter %s: %r", repo);
+	}
 	if(chdir("/") == -1)
 		sysfatal("chdir: %r");
 	if(access(".git", AREAD) == -1)