git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 2/6] send-pack: extract parsing of "unpack" response

From
Jeff King <peff@peff.net>
Date
Mar 7, 2017, 13:35 UTC
Message-ID
<20170307133557.xoqv6kigxzakgysi@sigill.intra.peff.net>
In-Reply-To
<20170307133437.qee2jtynbiwf6uzr@sigill.intra.peff.net>

After sending the pack, we call receive_status() which gets both the "unpack" line and the ref status. Let's break these into two functions so we can call the first part independently.

Signed-off-by: Jeff King <peff@peff.net>
---
 send-pack.c | 23 ++++++++++++++---------
 1 file changed, 14 insertions(+), 9 deletions(-)
diff --git a/send-pack.c b/send-pack.c
index 6195b43e9..12e229e44 100644
--- a/send-pack.c
+++ b/send-pack.c
@@ -130,22 +130,27 @@ static int pack_objects(int fd, struct ref *refs, struct sha1_array *extra, stru
 	return 0;
 }
 
-static int receive_status(int in, struct ref *refs)
+static int receive_unpack_status(int in)
 {
-	struct ref *hint;
-	int ret = 0;
-	char *line = packet_read_line(in, NULL);
+	const char *line = packet_read_line(in, NULL);
 	if (!starts_with(line, "unpack "))
 		return error("did not receive remote status");
-	if (strcmp(line, "unpack ok")) {
-		error("unpack failed: %s", line + 7);
-		ret = -1;
-	}
+	if (strcmp(line, "unpack ok"))
+		return error("unpack failed: %s", line + 7);
+	return 0;
+}
+
+static int receive_status(int in, struct ref *refs)
+{
+	struct ref *hint;
+	int ret;
+
 	hint = NULL;
+	ret = receive_unpack_status(in);
 	while (1) {
 		char *refname;
 		char *msg;
-		line = packet_read_line(in, NULL);
+		char *line = packet_read_line(in, NULL);
 		if (!line)
 			break;
 		if (!starts_with(line, "ok ") && !starts_with(line, "ng ")) {
-- 
2.12.0.429.gde83c8049
Previous: Jeff KingNext: Jeff King
Message 3 of 12 in “deadlock regression in v2.11.0 with failed mkdtemp”
  1. 0/6 deadlock regression in v2.11.0 with failed mkdtempJeff King, Mar 7, 2017
  2. 1/6 receive-pack: fix deadlock when we cannot create tmpdirJeff King, Mar 7, 2017
  3. 2/6 send-pack: extract parsing of "unpack" responseJeff King, Mar 7, 2017
  4. 6/6 send-pack: report signal death of pack-objectsJeff King, Mar 7, 2017
  5. 5/6 send-pack: read "unpack" status even on pack-objects failureJeff King, Mar 7, 2017
  6. 4/6 send-pack: improve unpack-status error messagesJeff King, Mar 7, 2017
  7. Junio C HamanoMar 7, 2017
  8. Jeff KingMar 8, 2017
  9. Junio C HamanoMar 8, 2017
  10. Jeff KingMar 7, 2017
  11. 3/6 send-pack: use skip_prefix for parsing unpack statusJeff King, Mar 7, 2017
  12. Horst SchirmeierMar 8, 2017

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.