git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
Nicolas Pitre <nico@cam.org>
Date
Oct 17, 2007, 01:55 UTC
Message-ID
<1192586150-13743-3-git-send-email-nico@cam.org>
In-Reply-To
<1192586150-13743-2-git-send-email-nico@cam.org>

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
Previous: Nicolas PitreNext: Nicolas Pitre
Message 3 of 17 in “miscelaneous stuff”
  1. 0/6 miscelaneous stuffNicolas Pitre, Oct 17, 2007
  2. 1/6 more compact progress displayNicolas Pitre, Oct 17, 2007
  3. 2/6 cope with multiple line breaks within sideband progress messagesNicolas Pitre, Oct 17, 2007
  4. 3/6 pack-objects: no delta possible with only one object in the listNicolas Pitre, Oct 17, 2007
  5. 4/6 pack-objects.c: fix some global variable abuse and memory leaksNicolas Pitre, Oct 17, 2007
  6. 5/6 fix const issues with some functionsNicolas Pitre, Oct 17, 2007
  7. 6/6 fix for more minor memory leaksNicolas Pitre, Oct 17, 2007
  8. Deltifying? (was [PATCH 3/6] pack-objects: no delta possible...)Shawn O. Pearce, Oct 17, 2007
  9. Nicolas PitreOct 17, 2007
  10. Shawn O. PearceOct 17, 2007
  11. Nicolas PitreOct 17, 2007
  12. Karl HasselströmOct 17, 2007
  13. Nicolas PitreOct 17, 2007
  14. Shawn O. PearceOct 18, 2007
  15. Karl HasselströmOct 18, 2007
  16. Johannes SixtOct 17, 2007
  17. Shawn O. PearceOct 17, 2007

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.