diff mbox series

[v3,2/2] sideband: report unhandled incomplete sideband messages as bugs

Message ID 9ffcc5b78e358d0ed4da2c52ba87174dc94e544c.1603728555.git.gitgitgadget@gmail.com (mailing list archive)
State New, archived
Headers show
Series Work around flakiness in t5500.43 | expand

Commit Message

Johannes Schindelin Oct. 26, 2020, 4:09 p.m. UTC
From: Johannes Schindelin <johannes.schindelin@gmx.de>

It was pretty tricky to verify that incomplete sideband messages are
handled correctly by the `recv_sideband()`/`demultiplex_sideband()`
code: they have to be flushed out at the end of the loop in
`recv_sideband()`, but the actual flushing is done by the
`demultiplex_sideband()` function (which therefore has to know somehow
that the loop will be done after it returns).

To catch future bugs where incomplete sideband messages might not be
shown by mistake, let's catch that condition and report a bug.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
 pkt-line.c | 3 +++
 1 file changed, 3 insertions(+)
diff mbox series


diff --git a/pkt-line.c b/pkt-line.c
index 844c253ccd..657a702927 100644
--- a/pkt-line.c
+++ b/pkt-line.c
@@ -471,6 +471,9 @@  int recv_sideband(const char *me, int in_stream, int out)
 			write_or_die(out, buf + 1, len - 1);
 		default: /* errors: message already written */
+			if (scratch.len > 0)
+				BUG("unhandled incomplete sideband: '%s'",
+				    scratch.buf);
 			return sideband_type;