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>
Felipe Contreras committed
Apr 12, 2014 at 15:33 UTC
0551a06c22543d4ff1aecbdf6b419760b1b10bff
1 file changed
+11
-7
transport-helper.c
+11
-7
@@ -739,17 +739,22 @@ static int push_update_ref_status(struct strbuf *buf,
739
return !(status == REF_STATUS_OK);
740
}
741
742
-static void push_update_refs_status(struct helper_data *data,
742
+static int push_update_refs_status(struct helper_data *data,
743
struct ref *remote_refs,
744
int flags)
745
{
746
struct strbuf buf = STRBUF_INIT;
747
struct ref *ref = remote_refs;
748
+ int ret = 0;
749
+
750
for (;;) {
751
char *private;
752
751
- if (recvline(data, &buf))
752
- exit(128);
753
+ if (recvline(data, &buf)) {
754
+ ret = 1;
755
+ break;
756
+ }
757
+
758
if (!buf.len)
759
break;
760
@@ -767,6 +772,7 @@ static void push_update_refs_status(struct helper_data *data,
772
free(private);
773
}
774
strbuf_release(&buf);
775
+ return ret;
776
}
777
778
static int push_refs_with_push(struct transport *transport,
@@ -847,8 +853,7 @@ static int push_refs_with_push(struct transport *transport,
853
sendline(data, &buf);
854
strbuf_release(&buf);
855
850
- push_update_refs_status(data, remote_refs, flags);
851
- return 0;
856
+ return push_update_refs_status(data, remote_refs, flags);
857
}
858
859
static int push_refs_with_export(struct transport *transport,
@@ -906,8 +911,7 @@ static int push_refs_with_export(struct transport *transport,
911
912
if (finish_command(&exporter))
913
die("Error while running fast-export");
909
- push_update_refs_status(data, remote_refs, flags);
910
- return 0;
914
+ return push_update_refs_status(data, remote_refs, flags);
915
}
916
917
static int push_refs(struct transport *transport,