Skip to content

Commit 5501d93

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 64457ed commit 5501d93

File tree

3 files changed

+19
-2
lines changed

3 files changed

+19
-2
lines changed

builtin/clone.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1166,7 +1166,9 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
11661166
}
11671167

11681168
if (!is_local && !complete_refs_before_fetch)
1169-
transport_fetch_refs(transport, mapped_refs);
1169+
if (transport_fetch_refs(transport, mapped_refs))
1170+
die(_("could not fetch refs from %s"),
1171+
transport->url);
11701172

11711173
remote_head = find_ref_by_name(refs, "HEAD");
11721174
remote_head_points_at =

t/t5801-remote-helpers.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ test_expect_success 'push update refs failure' '
228228
echo "update fail" >>file &&
229229
git commit -a -m "update fail" &&
230230
git rev-parse --verify testgit/origin/heads/update >expect &&
231-
test_expect_code 1 env GIT_REMOTE_TESTGIT_FAILURE="non-fast forward" \
231+
test_must_fail env GIT_REMOTE_TESTGIT_FAILURE="non-fast forward" \
232232
git push origin update &&
233233
git rev-parse --verify testgit/origin/heads/update >actual &&
234234
test_cmp expect actual

transport-helper.c

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

469+
static void check_helper_status(struct helper_data *data)
470+
{
471+
int pid, status;
472+
473+
pid = waitpid(data->helper->pid, &status, WNOHANG);
474+
if (pid < 0)
475+
die("Could not retrieve status of remote helper '%s'",
476+
data->name);
477+
if (pid > 0 && WIFEXITED(status))
478+
die("Remote helper '%s' died with %d",
479+
data->name, WEXITSTATUS(status));
480+
}
481+
469482
static int fetch_with_import(struct transport *transport,
470483
int nr_heads, struct ref **to_fetch)
471484
{
@@ -502,6 +515,7 @@ static int fetch_with_import(struct transport *transport,
502515

503516
if (finish_command(&fastimport))
504517
die(_("error while running fast-import"));
518+
check_helper_status(data);
505519

506520
/*
507521
* The fast-import stream of a remote helper that advertises
@@ -989,6 +1003,7 @@ static int push_refs_with_export(struct transport *transport,
9891003

9901004
if (finish_command(&exporter))
9911005
die(_("error while running fast-export"));
1006+
check_helper_status(data);
9921007
if (push_update_refs_status(data, remote_refs, flags))
9931008
return 1;
9941009

0 commit comments

Comments
 (0)