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>maint
parent
6cdad1f133
commit
7c39df2979
23
send-pack.c
23
send-pack.c
|
@ -130,22 +130,27 @@ static int pack_objects(int fd, struct ref *refs, struct sha1_array *extra, stru
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int receive_unpack_status(int in)
|
||||||
|
{
|
||||||
|
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"))
|
||||||
|
return error("unpack failed: %s", line + 7);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static int receive_status(int in, struct ref *refs)
|
static int receive_status(int in, struct ref *refs)
|
||||||
{
|
{
|
||||||
struct ref *hint;
|
struct ref *hint;
|
||||||
int ret = 0;
|
int ret;
|
||||||
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;
|
|
||||||
}
|
|
||||||
hint = NULL;
|
hint = NULL;
|
||||||
|
ret = receive_unpack_status(in);
|
||||||
while (1) {
|
while (1) {
|
||||||
char *refname;
|
char *refname;
|
||||||
char *msg;
|
char *msg;
|
||||||
line = packet_read_line(in, NULL);
|
char *line = packet_read_line(in, NULL);
|
||||||
if (!line)
|
if (!line)
|
||||||
break;
|
break;
|
||||||
if (!starts_with(line, "ok ") && !starts_with(line, "ng ")) {
|
if (!starts_with(line, "ok ") && !starts_with(line, "ng ")) {
|
||||||
|
|
Loading…
Reference in New Issue