summaryrefslogtreecommitdiff
path: root/send-pack.c
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2017-03-07 13:35:57 (GMT)
committerJunio C Hamano <gitster@pobox.com>2017-03-07 22:51:20 (GMT)
commit7c39df2979733e0041db7aff09c3f3a53b980ef2 (patch)
tree696ab868e976bfa3c8831005cd896b9922ee27d5 /send-pack.c
parent6cdad1f133475f2bff0dfe2fbe90c351df3ea61d (diff)
downloadgit-7c39df2979733e0041db7aff09c3f3a53b980ef2.zip
git-7c39df2979733e0041db7aff09c3f3a53b980ef2.tar.gz
git-7c39df2979733e0041db7aff09c3f3a53b980ef2.tar.bz2
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>
Diffstat (limited to 'send-pack.c')
-rw-r--r--send-pack.c23
1 files changed, 14 insertions, 9 deletions
diff --git a/send-pack.c b/send-pack.c
index 6195b43..12e229e 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 ")) {