Skip to content

Commit 43eb62b

Browse files
SRabbeliernalla
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 03348ae commit 43eb62b

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
@@ -962,7 +962,9 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
962962
}
963963

964964
if (!is_local && !complete_refs_before_fetch)
965-
transport_fetch_refs(transport, mapped_refs);
965+
if (transport_fetch_refs(transport, mapped_refs))
966+
die(_("could not fetch refs from %s"),
967+
transport->url);
966968

967969
remote_head = find_ref_by_name(refs, "HEAD");
968970
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
@@ -429,6 +429,19 @@ static int get_exporter(struct transport *transport,
429429
return start_command(fastexport);
430430
}
431431

432+
static void check_helper_status(struct helper_data *data)
433+
{
434+
int pid, status;
435+
436+
pid = waitpid(data->helper->pid, &status, WNOHANG);
437+
if (pid < 0)
438+
die("Could not retrieve status of remote helper '%s'",
439+
data->name);
440+
if (pid > 0 && WIFEXITED(status))
441+
die("Remote helper '%s' died with %d",
442+
data->name, WEXITSTATUS(status));
443+
}
444+
432445
static int fetch_with_import(struct transport *transport,
433446
int nr_heads, struct ref **to_fetch)
434447
{
@@ -465,6 +478,7 @@ static int fetch_with_import(struct transport *transport,
465478

466479
if (finish_command(&fastimport))
467480
die("Error while running fast-import");
481+
check_helper_status(data);
468482

469483
/*
470484
* The fast-import stream of a remote helper that advertises
@@ -923,6 +937,7 @@ static int push_refs_with_export(struct transport *transport,
923937

924938
if (finish_command(&exporter))
925939
die("Error while running fast-export");
940+
check_helper_status(data);
926941
if (push_update_refs_status(data, remote_refs, flags))
927942
return 1;
928943

0 commit comments

Comments
 (0)