diff options
author | Nicolas Pitre <nico@cam.org> | 2007-10-16 21:55:46 -0400 |
---|---|---|
committer | Shawn O. Pearce <spearce@spearce.org> | 2007-10-17 02:54:56 -0400 |
commit | ed1902ef5c6a30942def50809b52e41fbdcdf13f (patch) | |
tree | a3efcb9b40ad7dfd16082abff6dc7bb3cab66911 | |
parent | 42e18fbf5f94dd6bd303bf702e030a29fa39d6c4 (diff) | |
download | git-ed1902ef5c6a30942def50809b52e41fbdcdf13f.tar.gz |
cope with multiple line breaks within sideband progress messages
A single sideband packet may sometimes contain multiple lines of progress
messages, but we prepend "remote: " only to the whole buffer which creates
a messed up display in that case. Make sure that the "remote: " prefix
is applied to every remote lines.
Signed-off-by: Nicolas Pitre <nico@cam.org>
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
-rw-r--r-- | sideband.c | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/sideband.c b/sideband.c index 277fa3c10d..ab8a1e990d 100644 --- a/sideband.c +++ b/sideband.c @@ -17,7 +17,7 @@ int recv_sideband(const char *me, int in_stream, int out, int err) strcpy(buf, "remote:"); while (1) { int band, len; - len = packet_read_line(in_stream, buf+7, LARGE_PACKET_MAX); + len = packet_read_line(in_stream, buf+7, LARGE_PACKET_MAX); if (len == 0) break; if (len < 1) { @@ -35,7 +35,22 @@ int recv_sideband(const char *me, int in_stream, int out, int err) return SIDEBAND_REMOTE_ERROR; case 2: buf[7] = ' '; - safe_write(err, buf, 8+len); + len += 8; + while (1) { + int brk = 8; + while (brk < len) { + brk++; + if (buf[brk-1] == '\n' || + buf[brk-1] == '\r') + break; + } + safe_write(err, buf, brk); + if (brk < len) { + memmove(buf + 8, buf + brk, len - brk); + len = len - brk + 8; + } else + break; + } continue; case 1: safe_write(out, buf+8, len); |