Merge branch 'jk/diag-unexpected-remote-helper-death'
When a remote-helper dies before Git writes to it, SIGPIPE killed Git silently. We now explain the situation a bit better to the end user in our error message. * jk/diag-unexpected-remote-helper-death: print an error when remote helpers die during capabilities
This commit is contained in:
@ -344,4 +344,15 @@ test_expect_success 'fetch tag' '
|
|||||||
compare_refs local v1.0 server v1.0
|
compare_refs local v1.0 server v1.0
|
||||||
'
|
'
|
||||||
|
|
||||||
|
test_expect_success 'totally broken helper reports failure message' '
|
||||||
|
write_script git-remote-broken <<-\EOF &&
|
||||||
|
read cap_cmd
|
||||||
|
exit 1
|
||||||
|
EOF
|
||||||
|
test_must_fail \
|
||||||
|
env PATH="$PWD:$PATH" \
|
||||||
|
git clone broken://example.com/foo.git 2>stderr &&
|
||||||
|
grep aborted stderr
|
||||||
|
'
|
||||||
|
|
||||||
test_done
|
test_done
|
||||||
|
@ -89,11 +89,18 @@ static int recvline(struct helper_data *helper, struct strbuf *buffer)
|
|||||||
return recvline_fh(helper->out, buffer);
|
return recvline_fh(helper->out, buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void write_constant(int fd, const char *str)
|
static int write_constant_gently(int fd, const char *str)
|
||||||
{
|
{
|
||||||
if (debug)
|
if (debug)
|
||||||
fprintf(stderr, "Debug: Remote helper: -> %s", str);
|
fprintf(stderr, "Debug: Remote helper: -> %s", str);
|
||||||
if (write_in_full(fd, str, strlen(str)) < 0)
|
if (write_in_full(fd, str, strlen(str)) < 0)
|
||||||
|
return -1;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void write_constant(int fd, const char *str)
|
||||||
|
{
|
||||||
|
if (write_constant_gently(fd, str) < 0)
|
||||||
die_errno(_("full write to remote helper failed"));
|
die_errno(_("full write to remote helper failed"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -168,13 +175,16 @@ static struct child_process *get_helper(struct transport *transport)
|
|||||||
die_errno(_("can't dup helper output fd"));
|
die_errno(_("can't dup helper output fd"));
|
||||||
data->out = xfdopen(duped, "r");
|
data->out = xfdopen(duped, "r");
|
||||||
|
|
||||||
write_constant(helper->in, "capabilities\n");
|
sigchain_push(SIGPIPE, SIG_IGN);
|
||||||
|
if (write_constant_gently(helper->in, "capabilities\n") < 0)
|
||||||
|
die("remote helper '%s' aborted session", data->name);
|
||||||
|
sigchain_pop(SIGPIPE);
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
const char *capname, *arg;
|
const char *capname, *arg;
|
||||||
int mandatory = 0;
|
int mandatory = 0;
|
||||||
if (recvline(data, &buf))
|
if (recvline(data, &buf))
|
||||||
exit(128);
|
die("remote helper '%s' aborted session", data->name);
|
||||||
|
|
||||||
if (!*buf.buf)
|
if (!*buf.buf)
|
||||||
break;
|
break;
|
||||||
|
Reference in New Issue
Block a user