[PATCH 2/6] cope with multiple line breaks within sideband progress messages

!MAILaRCHIVE_VOTE_RePLACE
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: Shawn O. Pearce <spearce@...>
Cc: <git@...>
Date: Tuesday, October 16, 2007 - 9:55 pm

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>
---
 sideband.c |   19 +++++++++++++++++--
 1 files changed, 17 insertions(+), 2 deletions(-)

diff --git a/sideband.c b/sideband.c
index 277fa3c..ab8a1e9 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);
-- 
1.5.3.4.1212.gdb015

-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH 0/6] miscelaneous stuff, Nicolas Pitre, (Tue Oct 16, 9:55 pm)
[PATCH 1/6] more compact progress display, Nicolas Pitre, (Tue Oct 16, 9:55 pm)
Re: [PATCH 1/6] more compact progress display, Johannes Sixt, (Wed Oct 17, 2:34 am)
Re: [PATCH 1/6] more compact progress display, Shawn O. Pearce, (Wed Oct 17, 2:37 am)
Re: [PATCH 1/6] more compact progress display, Shawn O. Pearce, (Tue Oct 16, 10:11 pm)
Re: [PATCH 1/6] more compact progress display, Karl , (Wed Oct 17, 4:20 am)
Re: [PATCH 1/6] more compact progress display, Nicolas Pitre, (Wed Oct 17, 4:56 pm)
Re: [PATCH 1/6] more compact progress display, Karl , (Thu Oct 18, 4:34 am)
Re: [PATCH 1/6] more compact progress display, Shawn O. Pearce, (Thu Oct 18, 12:58 am)
Re: [PATCH 1/6] more compact progress display, Nicolas Pitre, (Tue Oct 16, 10:24 pm)
[PATCH 2/6] cope with multiple line breaks within sideband p..., Nicolas Pitre, (Tue Oct 16, 9:55 pm)