From: Lukas Fleischer Date: Tue, 28 Jun 2016 04:35:26 +0000 (+0200) Subject: sideband.c: refactor recv_sideband() X-Git-Tag: v2.9.3~32^2~1 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/5e5be9e257239b3599701f05518ce9e45f565e9f?hp=5e5be9e257239b3599701f05518ce9e45f565e9f sideband.c: refactor recv_sideband() We used character buffer manipulations to split messages from the sideband at line breaks and insert "remote: " at the beginning of each line, using the packet size to determine the end of a message. However, since it is safe to assume that diagnostic messages from the sideband never contain NUL characters, we can also NUL-terminate the buffer, use strpbrk() for splitting lines and use format strings to insert the prefix, to make the code easier to read and maintain. A strbuf is used for accumulating the output which is then printed using a single write(2) call to ensure the atomicity of the output. See 9ac13ec (atomic write for sideband remote messages, 2006-10-11) for details. Helped-by: Jeff King Helped-by: Junio C Hamano Helped-by: Nicolas Pitre Signed-off-by: Lukas Fleischer Signed-off-by: Junio C Hamano ---