Skip to content

Commit 5931b33

Browse files
felipecgitster
authored andcommitted
remote-helpers: make recvline return an error
Instead of exiting directly, make it the duty of the caller to do so. Signed-off-by: Felipe Contreras <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 4a1b59c commit 5931b33

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

transport-helper.c

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ static int recvline_fh(FILE *helper, struct strbuf *buffer, const char *name)
5858
if (strbuf_getline(buffer, helper, '\n') == EOF) {
5959
if (debug)
6060
fprintf(stderr, "Debug: Remote helper quit.\n");
61-
exit(128);
61+
return 1;
6262
}
6363

6464
if (debug)
@@ -157,7 +157,8 @@ static struct child_process *get_helper(struct transport *transport)
157157
while (1) {
158158
const char *capname;
159159
int mandatory = 0;
160-
recvline(data, &buf);
160+
if (recvline(data, &buf))
161+
exit(128);
161162

162163
if (!*buf.buf)
163164
break;
@@ -302,7 +303,8 @@ static int set_helper_option(struct transport *transport,
302303
strbuf_addch(&buf, '\n');
303304

304305
sendline(data, &buf);
305-
recvline(data, &buf);
306+
if (recvline(data, &buf))
307+
exit(128);
306308

307309
if (!strcmp(buf.buf, "ok"))
308310
ret = 0;
@@ -374,7 +376,8 @@ static int fetch_with_fetch(struct transport *transport,
374376
sendline(data, &buf);
375377

376378
while (1) {
377-
recvline(data, &buf);
379+
if (recvline(data, &buf))
380+
exit(128);
378381

379382
if (starts_with(buf.buf, "lock ")) {
380383
const char *name = buf.buf + 5;
@@ -558,7 +561,9 @@ static int process_connect_service(struct transport *transport,
558561
goto exit;
559562

560563
sendline(data, &cmdbuf);
561-
recvline_fh(input, &cmdbuf, name);
564+
if (recvline_fh(input, &cmdbuf, name))
565+
exit(128);
566+
562567
if (!strcmp(cmdbuf.buf, "")) {
563568
data->no_disconnect_req = 1;
564569
if (debug)
@@ -743,7 +748,8 @@ static void push_update_refs_status(struct helper_data *data,
743748
for (;;) {
744749
char *private;
745750

746-
recvline(data, &buf);
751+
if (recvline(data, &buf))
752+
exit(128);
747753
if (!buf.len)
748754
break;
749755

@@ -969,7 +975,8 @@ static struct ref *get_refs_list(struct transport *transport, int for_push)
969975

970976
while (1) {
971977
char *eov, *eon;
972-
recvline(data, &buf);
978+
if (recvline(data, &buf))
979+
exit(128);
973980

974981
if (!*buf.buf)
975982
break;

0 commit comments

Comments
 (0)