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

[PATCH 3/6] send-pack: use skip_prefix for parsing unpack status

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

This avoids repeating ourselves, and the use of magic numbers.

Signed-off-by: Jeff King <peff@peff.net>
---
Obviously not necessary, but just a cleanup while I was here.
 send-pack.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/send-pack.c b/send-pack.c
index 12e229e44..243633da1 100644
--- a/send-pack.c
+++ b/send-pack.c
@@ -133,10 +133,10 @@ static int pack_objects(int fd, struct ref *refs, struct sha1_array *extra, stru
 static int receive_unpack_status(int in)
 {
 	const char *line = packet_read_line(in, NULL);
-	if (!starts_with(line, "unpack "))
+	if (!skip_prefix(line, "unpack ", &line))
 		return error("did not receive remote status");
-	if (strcmp(line, "unpack ok"))
-		return error("unpack failed: %s", line + 7);
+	if (strcmp(line, "ok"))
+		return error("unpack failed: %s", line);
 	return 0;
 }
 
-- 
2.12.0.429.gde83c8049
Previous: Jeff KingNext: Horst Schirmeier
Message 11 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.