mirror of
https://github.com/git/git
synced 2024-08-27 19:49:21 +00:00
Merge branch 'jk/receive-pack-unpack-error-to-pusher'
Send errors from "unpack-objects" and "index-pack" back to the "git push" over the git and smart-http protocols, just like it is done for a push over the ssh protocol. * jk/receive-pack-unpack-error-to-pusher: receive-pack: drop "n/a" on unpacker errors receive-pack: send pack-processing stderr over sideband receive-pack: redirect unpack-objects stdout to /dev/null
This commit is contained in:
commit
03b98d2e78
|
@ -695,7 +695,7 @@ static void execute_commands(struct command *commands, const char *unpacker_erro
|
||||||
|
|
||||||
if (unpacker_error) {
|
if (unpacker_error) {
|
||||||
for (cmd = commands; cmd; cmd = cmd->next)
|
for (cmd = commands; cmd; cmd = cmd->next)
|
||||||
cmd->error_string = "n/a (unpacker error)";
|
cmd->error_string = "unpacker error";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -795,7 +795,7 @@ static const char *parse_pack_header(struct pack_header *hdr)
|
||||||
|
|
||||||
static const char *pack_lockfile;
|
static const char *pack_lockfile;
|
||||||
|
|
||||||
static const char *unpack(void)
|
static const char *unpack(int err_fd)
|
||||||
{
|
{
|
||||||
struct pack_header hdr;
|
struct pack_header hdr;
|
||||||
const char *hdr_err;
|
const char *hdr_err;
|
||||||
|
@ -815,6 +815,7 @@ static const char *unpack(void)
|
||||||
|
|
||||||
if (ntohl(hdr.hdr_entries) < unpack_limit) {
|
if (ntohl(hdr.hdr_entries) < unpack_limit) {
|
||||||
int code, i = 0;
|
int code, i = 0;
|
||||||
|
struct child_process child;
|
||||||
const char *unpacker[5];
|
const char *unpacker[5];
|
||||||
unpacker[i++] = "unpack-objects";
|
unpacker[i++] = "unpack-objects";
|
||||||
if (quiet)
|
if (quiet)
|
||||||
|
@ -823,7 +824,12 @@ static const char *unpack(void)
|
||||||
unpacker[i++] = "--strict";
|
unpacker[i++] = "--strict";
|
||||||
unpacker[i++] = hdr_arg;
|
unpacker[i++] = hdr_arg;
|
||||||
unpacker[i++] = NULL;
|
unpacker[i++] = NULL;
|
||||||
code = run_command_v_opt(unpacker, RUN_GIT_CMD);
|
memset(&child, 0, sizeof(child));
|
||||||
|
child.argv = unpacker;
|
||||||
|
child.no_stdout = 1;
|
||||||
|
child.err = err_fd;
|
||||||
|
child.git_cmd = 1;
|
||||||
|
code = run_command(&child);
|
||||||
if (!code)
|
if (!code)
|
||||||
return NULL;
|
return NULL;
|
||||||
return "unpack-objects abnormal exit";
|
return "unpack-objects abnormal exit";
|
||||||
|
@ -848,6 +854,7 @@ static const char *unpack(void)
|
||||||
memset(&ip, 0, sizeof(ip));
|
memset(&ip, 0, sizeof(ip));
|
||||||
ip.argv = keeper;
|
ip.argv = keeper;
|
||||||
ip.out = -1;
|
ip.out = -1;
|
||||||
|
ip.err = err_fd;
|
||||||
ip.git_cmd = 1;
|
ip.git_cmd = 1;
|
||||||
status = start_command(&ip);
|
status = start_command(&ip);
|
||||||
if (status) {
|
if (status) {
|
||||||
|
@ -864,6 +871,26 @@ static const char *unpack(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static const char *unpack_with_sideband(void)
|
||||||
|
{
|
||||||
|
struct async muxer;
|
||||||
|
const char *ret;
|
||||||
|
|
||||||
|
if (!use_sideband)
|
||||||
|
return unpack(0);
|
||||||
|
|
||||||
|
memset(&muxer, 0, sizeof(muxer));
|
||||||
|
muxer.proc = copy_to_sideband;
|
||||||
|
muxer.in = -1;
|
||||||
|
if (start_async(&muxer))
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
ret = unpack(muxer.in);
|
||||||
|
|
||||||
|
finish_async(&muxer);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
static void report(struct command *commands, const char *unpack_status)
|
static void report(struct command *commands, const char *unpack_status)
|
||||||
{
|
{
|
||||||
struct command *cmd;
|
struct command *cmd;
|
||||||
|
@ -961,7 +988,7 @@ int cmd_receive_pack(int argc, const char **argv, const char *prefix)
|
||||||
const char *unpack_status = NULL;
|
const char *unpack_status = NULL;
|
||||||
|
|
||||||
if (!delete_only(commands))
|
if (!delete_only(commands))
|
||||||
unpack_status = unpack();
|
unpack_status = unpack_with_sideband();
|
||||||
execute_commands(commands, unpack_status);
|
execute_commands(commands, unpack_status);
|
||||||
if (pack_lockfile)
|
if (pack_lockfile)
|
||||||
unlink_or_warn(pack_lockfile);
|
unlink_or_warn(pack_lockfile);
|
||||||
|
|
|
@ -89,7 +89,7 @@ test_expect_success 'push with !receive.fsckobjects' '
|
||||||
|
|
||||||
cat >exp <<EOF
|
cat >exp <<EOF
|
||||||
To dst
|
To dst
|
||||||
! refs/heads/master:refs/heads/test [remote rejected] (n/a (unpacker error))
|
! refs/heads/master:refs/heads/test [remote rejected] (unpacker error)
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
test_expect_success 'push with receive.fsckobjects' '
|
test_expect_success 'push with receive.fsckobjects' '
|
||||||
|
|
Loading…
Reference in a new issue