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

Re: Git trims the last character of content from remotes

From
René Scharfe <l.s.r@web.de>
Date
May 5, 2026, 19:41 UTC
Message-ID
<3364c573-b7f4-4ec0-b471-312aa11028fe@web.de>
In-Reply-To
<CAPx1Gvf5Vts3oS2BdFQ4PpCR-UY=5cYW7fgOkRuQpi8ug2JXDg@mail.gmail.com>
On 5/5/26 2:34 AM, Chris Torek wrote:
Show 7 quoted lines
> On Mon, May 4, 2026 at 10:02 AM Hugo Osvaldo Barrera <hugo@whynothugo.nl> wrote:
> [snippage]
>> When the width of a whole line is the same as my terminal width ...
> [snippage]
>> ... sideband.c prints ANSI_SUFFIX = "\033[K", this escape
>> sequence being "clear the line from the current position until the end of the
>> line", and this is the root cause of the issue.
> If you have a non-empty prefix
> string before this "clear to end of line" suffix, the solution is more
> obvious: print the ESC [ K as a *prefix* rather than a suffix, but
> that fails with the empty prefix.

We do have a non-empty prefix, but why would it be necessary? What's wrong with clearing the full line starting from column 1?

Anyway, do you mean something like this?
diff --git a/sideband.c b/sideband.c
index ea7c25211e..5bfdd1d372 100644
--- a/sideband.c
+++ b/sideband.c
@@ -120,7 +120,7 @@ static void maybe_colorize_sideband(struct strbuf *dest, const char *src, int n)
 
 #define DISPLAY_PREFIX "remote: "
 
-#define ANSI_SUFFIX "\033[K"
+#define ANSI_PREFIX "\033[K"
 #define DUMB_SUFFIX "        "
 
 int demultiplex_sideband(const char *me, int status,
@@ -129,15 +129,19 @@ int demultiplex_sideband(const char *me, int status,
 			 struct strbuf *scratch,
 			 enum sideband_type *sideband_type)
 {
+	static const char *prefix;
 	static const char *suffix;
 	const char *b, *brk;
 	int band;
 
 	if (!suffix) {
-		if (isatty(2) && !is_terminal_dumb())
-			suffix = ANSI_SUFFIX;
-		else
+		if (isatty(2) && !is_terminal_dumb()) {
+			prefix = DISPLAY_PREFIX ANSI_PREFIX;
+			suffix = "";
+		} else {
+			prefix = DISPLAY_PREFIX;
 			suffix = DUMB_SUFFIX;
+		}
 	}
 
 	if (status == PACKET_READ_EOF) {
@@ -172,7 +176,7 @@ int demultiplex_sideband(const char *me, int status,
 		if (die_on_error)
 			die(_("remote error: %s"), buf + 1);
 		strbuf_addf(scratch, "%s%s", scratch->len ? "\n" : "",
-			    DISPLAY_PREFIX);
+			    prefix);
 		maybe_colorize_sideband(scratch, buf + 1, len);
 
 		*sideband_type = SIDEBAND_REMOTE_ERROR;
@@ -203,7 +207,7 @@ int demultiplex_sideband(const char *me, int status,
 				strbuf_addstr(scratch, suffix);
 
 			if (!scratch->len)
-				strbuf_addstr(scratch, DISPLAY_PREFIX);
+				strbuf_addstr(scratch, prefix);
 
 			/*
 			 * A use case that we should not add clear-to-eol suffix
@@ -230,7 +234,7 @@ int demultiplex_sideband(const char *me, int status,
 
 		if (*b) {
 			strbuf_addstr(scratch, scratch->len ?
-				    "" : DISPLAY_PREFIX);
+				    "" : prefix);
 			maybe_colorize_sideband(scratch, b, strlen(b));
 		}
 		return 0;
Previous: Chris TorekNext: Mikael Magnusson
Message 3 of 10 in “Git trims the last character of content from remotes”
  1. Hugo Osvaldo BarreraMay 4, 2026
  2. Chris TorekMay 5, 2026
  3. René ScharfeMay 5, 2026
  4. Mikael MagnussonMay 6, 2026
  5. Mikael MagnussonMay 6, 2026
  6. René ScharfeMay 6, 2026
  7. sideband: clear full line when printing remote messagesRené Scharfe, May 10, 2026
  8. Junio C HamanoMay 10, 2026
  9. Mikael MagnussonMay 5, 2026
  10. Junio C HamanoAug 3, 2026

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.