transport-helper: propagate recvline() error pushing

It's cleaner, and will allow us to do something sensible on errors
later.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Felipe Contreras
2014-04-12 15:33:30 -05:00
committed by Junio C Hamano
parent 5931b33e20
commit 0551a06c22

View File

@ -739,17 +739,22 @@ static int push_update_ref_status(struct strbuf *buf,
return !(status == REF_STATUS_OK); return !(status == REF_STATUS_OK);
} }
static void push_update_refs_status(struct helper_data *data, static int push_update_refs_status(struct helper_data *data,
struct ref *remote_refs, struct ref *remote_refs,
int flags) int flags)
{ {
struct strbuf buf = STRBUF_INIT; struct strbuf buf = STRBUF_INIT;
struct ref *ref = remote_refs; struct ref *ref = remote_refs;
int ret = 0;
for (;;) { for (;;) {
char *private; char *private;
if (recvline(data, &buf)) if (recvline(data, &buf)) {
exit(128); ret = 1;
break;
}
if (!buf.len) if (!buf.len)
break; break;
@ -767,6 +772,7 @@ static void push_update_refs_status(struct helper_data *data,
free(private); free(private);
} }
strbuf_release(&buf); strbuf_release(&buf);
return ret;
} }
static int push_refs_with_push(struct transport *transport, static int push_refs_with_push(struct transport *transport,
@ -847,8 +853,7 @@ static int push_refs_with_push(struct transport *transport,
sendline(data, &buf); sendline(data, &buf);
strbuf_release(&buf); strbuf_release(&buf);
push_update_refs_status(data, remote_refs, flags); return push_update_refs_status(data, remote_refs, flags);
return 0;
} }
static int push_refs_with_export(struct transport *transport, static int push_refs_with_export(struct transport *transport,
@ -906,8 +911,7 @@ static int push_refs_with_export(struct transport *transport,
if (finish_command(&exporter)) if (finish_command(&exporter))
die("Error while running fast-export"); die("Error while running fast-export");
push_update_refs_status(data, remote_refs, flags); return push_update_refs_status(data, remote_refs, flags);
return 0;
} }
static int push_refs(struct transport *transport, static int push_refs(struct transport *transport,