Skip to content

Commit d415092

Browse files
peffgitster
authored andcommitted
receive-pack: relay connectivity errors to sideband
If the connectivity check encounters a problem when receiving a push, the error output goes to receive-pack's stderr, whose destination depends on the protocol used (ssh tends to send it to the user, though without a "remote" prefix; http will generally eat it in the server's error log). The information should consistently go back to the user, as there is a reasonable chance their client is buggy and generating a bad pack. We can do so by muxing it over the sideband as we do with other sub-process stderr. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent d06303b commit d415092

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

builtin/receive-pack.c

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1317,21 +1317,37 @@ static void execute_commands(struct command *commands,
13171317
const char *unpacker_error,
13181318
struct shallow_info *si)
13191319
{
1320+
struct check_connected_options opt = CHECK_CONNECTED_INIT;
13201321
struct command *cmd;
13211322
unsigned char sha1[20];
13221323
struct iterate_data data;
1324+
struct async muxer;
1325+
int err_fd = 0;
13231326

13241327
if (unpacker_error) {
13251328
for (cmd = commands; cmd; cmd = cmd->next)
13261329
cmd->error_string = "unpacker error";
13271330
return;
13281331
}
13291332

1333+
if (use_sideband) {
1334+
memset(&muxer, 0, sizeof(muxer));
1335+
muxer.proc = copy_to_sideband;
1336+
muxer.in = -1;
1337+
if (!start_async(&muxer))
1338+
err_fd = muxer.in;
1339+
/* ...else, continue without relaying sideband */
1340+
}
1341+
13301342
data.cmds = commands;
13311343
data.si = si;
1332-
if (check_connected(iterate_receive_command_list, &data, NULL))
1344+
opt.err_fd = err_fd;
1345+
if (check_connected(iterate_receive_command_list, &data, &opt))
13331346
set_connectivity_errors(commands, si);
13341347

1348+
if (use_sideband)
1349+
finish_async(&muxer);
1350+
13351351
reject_updates_to_hidden(commands);
13361352

13371353
if (run_receive_hook(commands, "pre-receive", 0)) {

0 commit comments

Comments
 (0)