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 <srabbelier@gmail.com> Acked-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Sverre Rabbelier committed
Jul 16, 2011 at 15:03 UTC
cc567322acbfd5b32e61ab5d005352347cd7eeaf
1 file changed
+15
-8
transport-helper.c
+15
-8
@@ -209,6 +209,7 @@ static int disconnect_helper(struct transport *transport)
209
{
210
struct helper_data *data = transport->data;
211
struct strbuf buf = STRBUF_INIT;
212
+ int res = 0;
213
214
if (data->helper) {
215
if (debug)
@@ -220,13 +221,13 @@ static int disconnect_helper(struct transport *transport)
221
close(data->helper->in);
222
close(data->helper->out);
223
fclose(data->out);
223
- finish_command(data->helper);
224
+ res = finish_command(data->helper);
225
free((char *)data->helper->argv[0]);
226
free(data->helper->argv);
227
free(data->helper);
228
data->helper = NULL;
229
}
229
- return 0;
230
+ return res;
231
}
232
233
static const char *unsupported_options[] = {
@@ -304,12 +305,13 @@ static void standard_options(struct transport *t)
305
306
static int release_helper(struct transport *transport)
307
{
308
+ int res = 0;
309
struct helper_data *data = transport->data;
310
free_refspec(data->refspec_nr, data->refspecs);
311
data->refspecs = NULL;
310
- disconnect_helper(transport);
312
+ res = disconnect_helper(transport);
313
free(transport->data);
312
- return 0;
314
+ return res;
315
}
316
317
static int fetch_with_fetch(struct transport *transport,
@@ -415,8 +417,11 @@ static int fetch_with_import(struct transport *transport,
417
sendline(data, &buf);
418
strbuf_reset(&buf);
419
}
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
+
425
free(fastimport.argv);
426
fastimport.argv = NULL;
427
@@ -760,8 +765,10 @@ static int push_refs_with_export(struct transport *transport,
765
die("Couldn't run fast-export");
766
767
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");
772
return 0;
773
}
774