Skip to content

Commit bde1bb0

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 f830dfc commit bde1bb0

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
@@ -1187,7 +1187,9 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
11871187
}
11881188

11891189
if (!is_local && !complete_refs_before_fetch)
1190-
transport_fetch_refs(transport, mapped_refs);
1190+
if (transport_fetch_refs(transport, mapped_refs))
1191+
die(_("could not fetch refs from %s"),
1192+
transport->url);
11911193

11921194
remote_head = find_ref_by_name(refs, "HEAD");
11931195
remote_head_points_at =

t/t5801-remote-helpers.sh

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

transport-helper.c

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

478+
static void check_helper_status(struct helper_data *data)
479+
{
480+
int pid, status;
481+
482+
pid = waitpid(data->helper->pid, &status, WNOHANG);
483+
if (pid < 0)
484+
die("Could not retrieve status of remote helper '%s'",
485+
data->name);
486+
if (pid > 0 && WIFEXITED(status))
487+
die("Remote helper '%s' died with %d",
488+
data->name, WEXITSTATUS(status));
489+
}
490+
478491
static int fetch_with_import(struct transport *transport,
479492
int nr_heads, struct ref **to_fetch)
480493
{
@@ -511,6 +524,7 @@ static int fetch_with_import(struct transport *transport,
511524

512525
if (finish_command(&fastimport))
513526
die(_("error while running fast-import"));
527+
check_helper_status(data);
514528

515529
/*
516530
* The fast-import stream of a remote helper that advertises
@@ -1003,6 +1017,7 @@ static int push_refs_with_export(struct transport *transport,
10031017

10041018
if (finish_command(&exporter))
10051019
die(_("error while running fast-export"));
1020+
check_helper_status(data);
10061021
if (push_update_refs_status(data, remote_refs, flags))
10071022
return 1;
10081023

0 commit comments

Comments
 (0)