Skip to content

Commit

Permalink
remote-helper: check helper status after import/export
Browse files Browse the repository at this point in the history
Signed-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Signed-off-by: Sverre Rabbelier <srabbelier@gmail.com>
  • Loading branch information
SRabbelier authored and dscho committed Sep 18, 2024
1 parent f9372db commit 9a0537d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion t/t5801-remote-helpers.sh
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ test_expect_success 'push update refs failure' '
echo "update fail" >>file &&
git commit -a -m "update fail" &&
git rev-parse --verify testgit/origin/heads/update >expect &&
test_expect_code 1 env GIT_REMOTE_TESTGIT_FAILURE="non-fast forward" \
test_must_fail env GIT_REMOTE_TESTGIT_FAILURE="non-fast forward" \
git push origin update &&
git rev-parse --verify testgit/origin/heads/update >actual &&
test_cmp expect actual
Expand Down
15 changes: 15 additions & 0 deletions transport-helper.c
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,19 @@ static int get_exporter(struct transport *transport,
return start_command(fastexport);
}

static void check_helper_status(struct helper_data *data)
{
int pid, status;

pid = waitpid(data->helper->pid, &status, WNOHANG);
if (pid < 0)
die("Could not retrieve status of remote helper '%s'",
data->name);
if (pid > 0 && WIFEXITED(status))
die("Remote helper '%s' died with %d",
data->name, WEXITSTATUS(status));
}

static int fetch_with_import(struct transport *transport,
int nr_heads, struct ref **to_fetch)
{
Expand Down Expand Up @@ -530,6 +543,7 @@ static int fetch_with_import(struct transport *transport,

if (finish_command(&fastimport))
die(_("error while running fast-import"));
check_helper_status(data);

/*
* The fast-import stream of a remote helper that advertises
Expand Down Expand Up @@ -1142,6 +1156,7 @@ static int push_refs_with_export(struct transport *transport,

if (finish_command(&exporter))
die(_("error while running fast-export"));
check_helper_status(data);
if (push_update_refs_status(data, remote_refs, flags))
return 1;

Expand Down

0 comments on commit 9a0537d

Please sign in to comment.