Skip to content

Commit 8da7d7c

Browse files
SRabbelierdscho
authored andcommitted
remote-helper: check helper status after import/export
Signed-off-by: Johannes Schindelin <[email protected]> Signed-off-by: Sverre Rabbelier <[email protected]>
1 parent 50f0a12 commit 8da7d7c

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

t/t5801-remote-helpers.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ test_expect_success 'push update refs failure' '
262262
echo "update fail" >>file &&
263263
git commit -a -m "update fail" &&
264264
git rev-parse --verify testgit/origin/heads/update >expect &&
265-
test_expect_code 1 env GIT_REMOTE_TESTGIT_FAILURE="non-fast forward" \
265+
test_must_fail env GIT_REMOTE_TESTGIT_FAILURE="non-fast forward" \
266266
git push origin update &&
267267
git rev-parse --verify testgit/origin/heads/update >actual &&
268268
test_cmp expect actual

transport-helper.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -506,6 +506,19 @@ static int get_exporter(struct transport *transport,
506506
return start_command(fastexport);
507507
}
508508

509+
static void check_helper_status(struct helper_data *data)
510+
{
511+
int pid, status;
512+
513+
pid = waitpid(data->helper->pid, &status, WNOHANG);
514+
if (pid < 0)
515+
die("Could not retrieve status of remote helper '%s'",
516+
data->name);
517+
if (pid > 0 && WIFEXITED(status))
518+
die("Remote helper '%s' died with %d",
519+
data->name, WEXITSTATUS(status));
520+
}
521+
509522
static int fetch_with_import(struct transport *transport,
510523
int nr_heads, struct ref **to_fetch)
511524
{
@@ -542,6 +555,7 @@ static int fetch_with_import(struct transport *transport,
542555

543556
if (finish_command(&fastimport))
544557
die(_("error while running fast-import"));
558+
check_helper_status(data);
545559

546560
/*
547561
* The fast-import stream of a remote helper that advertises
@@ -1161,6 +1175,7 @@ static int push_refs_with_export(struct transport *transport,
11611175

11621176
if (finish_command(&exporter))
11631177
die(_("error while running fast-export"));
1178+
check_helper_status(data);
11641179
if (push_update_refs_status(data, remote_refs, flags))
11651180
return 1;
11661181

0 commit comments

Comments
 (0)