From: "René Scharfe" <l.s.r@web.de>
To: Chris Torek <chris.torek@gmail.com>,
Hugo Osvaldo Barrera <hugo@whynothugo.nl>
Cc: git@vger.kernel.org
Subject: Re: Git trims the last character of content from remotes
Date: Tue, 5 May 2026 21:41:00 +0200 [thread overview]
Message-ID: <3364c573-b7f4-4ec0-b471-312aa11028fe@web.de> (raw)
In-Reply-To: <CAPx1Gvf5Vts3oS2BdFQ4PpCR-UY=5cYW7fgOkRuQpi8ug2JXDg@mail.gmail.com>
On 5/5/26 2:34 AM, Chris Torek wrote:
> 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;
next prev parent reply other threads:[~2026-05-05 19:46 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-04 17:01 Git trims the last character of content from remotes Hugo Osvaldo Barrera
2026-05-05 0:34 ` Chris Torek
2026-05-05 19:41 ` René Scharfe [this message]
2026-05-06 9:37 ` Mikael Magnusson
2026-05-06 9:40 ` Mikael Magnusson
2026-05-06 16:00 ` René Scharfe
2026-05-10 12:42 ` [PATCH] sideband: clear full line when printing remote messages René Scharfe
2026-05-10 23:30 ` Junio C Hamano
2026-05-05 9:38 ` Git trims the last character of content from remotes Mikael Magnusson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=3364c573-b7f4-4ec0-b471-312aa11028fe@web.de \
--to=l.s.r@web.de \
--cc=chris.torek@gmail.com \
--cc=git@vger.kernel.org \
--cc=hugo@whynothugo.nl \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox