mirror of
https://github.com/git/git
synced 2024-08-27 19:49:21 +00:00
Merge branch 'js/avoid-split-sideband-message'
The side-band status report can be sent at the same time as the primary payload multiplexed, but the demultiplexer on the receiving end incorrectly split a single status report into two, which has been corrected. * js/avoid-split-sideband-message: test-pkt-line: drop colon from sideband identity sideband: report unhandled incomplete sideband messages as bugs sideband: avoid reporting incomplete sideband messages
This commit is contained in:
commit
6b9f5096eb
|
@ -471,6 +471,9 @@ int recv_sideband(const char *me, int in_stream, int out)
|
|||
write_or_die(out, buf + 1, len - 1);
|
||||
break;
|
||||
default: /* errors: message already written */
|
||||
if (scratch.len > 0)
|
||||
BUG("unhandled incomplete sideband: '%s'",
|
||||
scratch.buf);
|
||||
return sideband_type;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -190,7 +190,7 @@ int demultiplex_sideband(const char *me, char *buf, int len,
|
|||
return 0;
|
||||
case 1:
|
||||
*sideband_type = SIDEBAND_PRIMARY;
|
||||
break;
|
||||
return 1;
|
||||
default:
|
||||
strbuf_addf(scratch, "%s%s: protocol error: bad band #%d",
|
||||
scratch->len ? "\n" : "", me, band);
|
||||
|
|
|
@ -84,6 +84,25 @@ static void unpack_sideband(void)
|
|||
}
|
||||
}
|
||||
|
||||
static int send_split_sideband(void)
|
||||
{
|
||||
const char *part1 = "Hello,";
|
||||
const char *primary = "\001primary: regular output\n";
|
||||
const char *part2 = " world!\n";
|
||||
|
||||
send_sideband(1, 2, part1, strlen(part1), LARGE_PACKET_MAX);
|
||||
packet_write(1, primary, strlen(primary));
|
||||
send_sideband(1, 2, part2, strlen(part2), LARGE_PACKET_MAX);
|
||||
packet_response_end(1);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int receive_sideband(void)
|
||||
{
|
||||
return recv_sideband("sideband", 0, 1);
|
||||
}
|
||||
|
||||
int cmd__pkt_line(int argc, const char **argv)
|
||||
{
|
||||
if (argc < 2)
|
||||
|
@ -95,6 +114,10 @@ int cmd__pkt_line(int argc, const char **argv)
|
|||
unpack();
|
||||
else if (!strcmp(argv[1], "unpack-sideband"))
|
||||
unpack_sideband();
|
||||
else if (!strcmp(argv[1], "send-split-sideband"))
|
||||
send_split_sideband();
|
||||
else if (!strcmp(argv[1], "receive-sideband"))
|
||||
receive_sideband();
|
||||
else
|
||||
die("invalid argument '%s'", argv[1]);
|
||||
|
||||
|
|
|
@ -34,4 +34,10 @@ test_expect_success 'check for a bug in the regex routines' '
|
|||
test-tool regex --bug
|
||||
'
|
||||
|
||||
test_expect_success 'incomplete sideband messages are reassembled' '
|
||||
test-tool pkt-line send-split-sideband >split-sideband &&
|
||||
test-tool pkt-line receive-sideband <split-sideband 2>err &&
|
||||
grep "Hello, world" err
|
||||
'
|
||||
|
||||
test_done
|
||||
|
|
Loading…
Reference in a new issue