Commit Diff


commit - 1b3e8e8674ebd24834b549a70d90487307d0f3bf
commit + 2ff9f0818d453fcbfcf4843b368604f277cf4458
blob - 85ee3e8503a054b2d587e80262d305695c1c8449
blob + b8131d3c9afbbd434818c6c64743b9be8d7edf13
--- lib/serve.c
+++ lib/serve.c
@@ -220,7 +220,7 @@ send_ref(int outfd, uint8_t *id, const char *refname, 
 }
 
 static const struct got_error *
-send_zero_refs(int outfd, int chattygot)
+send_zero_refs(int outfd, int client_is_reading, int chattygot)
 {
 	const struct got_error *err = NULL;
 	char buf[GOT_PKT_MAX];
@@ -237,10 +237,18 @@ send_zero_refs(int outfd, int chattygot)
 	if (len >= sizeof(buf))
 		return got_error(GOT_ERR_NO_SPACE);
 
-	err = got_gitproto_append_capabilities(&capalen, buf, len,
-	    sizeof(buf), read_capabilities, nitems(read_capabilities));
-	if (err)
-		return err;
+	if (client_is_reading) {
+		err = got_gitproto_append_capabilities(&capalen, buf, len,
+		    sizeof(buf), read_capabilities, nitems(read_capabilities));
+		if (err)
+			return err;
+	} else {
+		err = got_gitproto_append_capabilities(&capalen, buf, len,
+		    sizeof(buf), write_capabilities,
+		    nitems(write_capabilities));
+		if (err)
+			return err;
+	}
 
 	return got_pkt_writepkt(outfd, buf, len + capalen, chattygot);
 }
@@ -315,7 +323,8 @@ announce_refs(int outfd, struct imsgbuf *ibuf, int cli
 			nrefs = ireflist.nrefs;
 			have_nrefs = 1;
 			if (nrefs == 0)
-				err = send_zero_refs(outfd, chattygot);
+				err = send_zero_refs(outfd, client_is_reading,
+				    chattygot);
 			break;
 		case GOTD_IMSG_REF:
 			if (!have_nrefs || nrefs == 0) {