send-pack: extract parsing of "unpack" response

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> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Jeff King committed Mar 7, 2017 at 08:35 UTC 7c39df2979733e0041db7aff09c3f3a53b980ef2
1 file changed +14 -9
send-pack.c
+14 -9
@@ -130,22 +130,27 @@ static int pack_objects(int fd, struct ref *refs, struct sha1_array *extra, stru
130 return 0;
131 }
132
133 -static int receive_status(int in, struct ref *refs)
133 +static int receive_unpack_status(int in)
134 {
135 - struct ref *hint;
136 - int ret = 0;
137 - char *line = packet_read_line(in, NULL);
135 + const char *line = packet_read_line(in, NULL);
136 if (!starts_with(line, "unpack "))
137 return error("did not receive remote status");
140 - if (strcmp(line, "unpack ok")) {
141 - error("unpack failed: %s", line + 7);
142 - ret = -1;
143 - }
138 + if (strcmp(line, "unpack ok"))
139 + return error("unpack failed: %s", line + 7);
140 + return 0;
141 +}
142 +
143 +static int receive_status(int in, struct ref *refs)
144 +{
145 + struct ref *hint;
146 + int ret;
147 +
148 hint = NULL;
149 + ret = receive_unpack_status(in);
150 while (1) {
151 char *refname;
152 char *msg;
148 - line = packet_read_line(in, NULL);
153 + char *line = packet_read_line(in, NULL);
154 if (!line)
155 break;
156 if (!starts_with(line, "ok ") && !starts_with(line, "ng ")) {