sideband: don't lose clear-to-eol at packet boundary
commit5210225f256d01938960d439bff9d809c2ff1809
authorJiang Xin <worldhello.net@gmail.com>
Thu, 17 Jun 2021 03:17:24 +0000 (17 11:17 +0800)
committerJunio C Hamano <gitster@pobox.com>
Thu, 17 Jun 2021 05:11:36 +0000 (17 14:11 +0900)
tree3fcbde188fad6d51627233e11e8a6c5f156dd58f
parent670b81a890388c60b7032a4f5b879f2ece8c4558
sideband: don't lose clear-to-eol at packet boundary

When "demultiplex_sideband()" sees a nonempty message ending with CR or
LF on the sideband #2, it adds "suffix" string to clear to the end of
the current line, which helps when relaying a progress display whose
records are terminated with CRs.  But if it sees a single LF, no
clear-to-end suffix should be appended, because this single LF is used
to end the progress display by moving to the next line, and the final
progress display above should be preserved.

However, the code forgot that depending on the length of the payload
line, such a CR may fall exactly at the packet boundary and the
number of bytes before the CR from the beginning of the packet could
be zero.  In such a case, the message that was terminated by the CR
were leftover in the "scratch" buffer in the previous call to the
function and we still need to clear to the end of the current line.

Helped-by: Junio C Hamano <gitster@pobox.com>
Helped-by: Nicolas Pitre <nico@fluxnic.net>
Signed-off-by: Jiang Xin <zhiyou.jx@alibaba-inc.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
sideband.c