]> git.ipfire.org Git - thirdparty/git.git/commitdiff
sideband: report unhandled incomplete sideband messages as bugs
authorJohannes Schindelin <johannes.schindelin@gmx.de>
Mon, 19 Oct 2020 19:35:41 +0000 (19:35 +0000)
committerJunio C Hamano <gitster@pobox.com>
Tue, 20 Oct 2020 20:31:02 +0000 (13:31 -0700)
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>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
pkt-line.c

index 844c253ccd9a9ee770fe494a0cce84f53dc8fed8..657a702927dbbdad837ec022e33cf30745a6e4ce 100644 (file)
@@ -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;
                }
        }