Skip to content

Commit cc56732

Browse files
SRabbeliergitster
authored andcommitted
transport-helper: check status code of finish_command
Previously the status code of all helpers were ignored, allowing errors that occur to go unnoticed if the error text output by the helper is not noticed. Signed-off-by: Sverre Rabbelier <[email protected]> Acked-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent d2e73c6 commit cc56732

File tree

1 file changed

+15
-8
lines changed

1 file changed

+15
-8
lines changed

transport-helper.c

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,7 @@ static int disconnect_helper(struct transport *transport)
209209
{
210210
struct helper_data *data = transport->data;
211211
struct strbuf buf = STRBUF_INIT;
212+
int res = 0;
212213

213214
if (data->helper) {
214215
if (debug)
@@ -220,13 +221,13 @@ static int disconnect_helper(struct transport *transport)
220221
close(data->helper->in);
221222
close(data->helper->out);
222223
fclose(data->out);
223-
finish_command(data->helper);
224+
res = finish_command(data->helper);
224225
free((char *)data->helper->argv[0]);
225226
free(data->helper->argv);
226227
free(data->helper);
227228
data->helper = NULL;
228229
}
229-
return 0;
230+
return res;
230231
}
231232

232233
static const char *unsupported_options[] = {
@@ -304,12 +305,13 @@ static void standard_options(struct transport *t)
304305

305306
static int release_helper(struct transport *transport)
306307
{
308+
int res = 0;
307309
struct helper_data *data = transport->data;
308310
free_refspec(data->refspec_nr, data->refspecs);
309311
data->refspecs = NULL;
310-
disconnect_helper(transport);
312+
res = disconnect_helper(transport);
311313
free(transport->data);
312-
return 0;
314+
return res;
313315
}
314316

315317
static int fetch_with_fetch(struct transport *transport,
@@ -415,8 +417,11 @@ static int fetch_with_import(struct transport *transport,
415417
sendline(data, &buf);
416418
strbuf_reset(&buf);
417419
}
418-
disconnect_helper(transport);
419-
finish_command(&fastimport);
420+
if (disconnect_helper(transport))
421+
die("Error while disconnecting helper");
422+
if (finish_command(&fastimport))
423+
die("Error while running fast-import");
424+
420425
free(fastimport.argv);
421426
fastimport.argv = NULL;
422427

@@ -760,8 +765,10 @@ static int push_refs_with_export(struct transport *transport,
760765
die("Couldn't run fast-export");
761766

762767
data->no_disconnect_req = 1;
763-
finish_command(&exporter);
764-
disconnect_helper(transport);
768+
if (finish_command(&exporter))
769+
die("Error while running fast-export");
770+
if (disconnect_helper(transport))
771+
die("Error while disconnecting helper");
765772
return 0;
766773
}
767774

0 commit comments

Comments
 (0)