Re: Git trims the last character of content from remotes
- From
- Mikael Magnusson <mikachu@gmail.com>
- Date
- May 5, 2026, 09:38 UTC
- Message-ID
- <CAHYJk3Qvx2i-K7ozLmwyA_S1tbRhf9i2EZa-5sfzBwC5aebeQg@mail.gmail.com>
- In-Reply-To
- <2d3f5504-f5dd-4171-96e8-b5633b6a1f5e@app.fastmail.com>
On Mon, May 4, 2026 at 7:02 PM Hugo Osvaldo Barrera <hugo@whynothugo.nl> wrote:
Show 25 quoted lines
> > Hi all, > > When I push content to GitLab, the remote server sends back some text which git > then prints to stderr: > > remote: > remote: To create a merge request for zk, visit: > remote: https://gitlab.alpinelinux.org/WhyNotHugo/aports/-/merge_requests/new?merge_request%5Bsource_branch%5D=zk > remote: > > When the width of a whole line is the same as my terminal width, the last digit > gets trimmed off. E.g.: if I resize my terminal for the above to fix exactly, > and re-run the same command, git prints: > > remote: https://gitlab.alpinelinux.org/WhyNotHugo/aports/-/merge_requests/new?merge_request%5Bsource_branch%5D=z > > From what I can tell, 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. > > When piping to cat or to a file, this sequence is not printed, so the output is > fine. > > Is this a bug?
grep has the same bug with --color, if you have a line of text the same width as your terminal, for the same reason. urxvt supports an extension of \e[3K to clear to end but not erase the character under the cursor if it's wrapped (but not yet moved to the next line). xterm hasn't picked it up though, so it's not a general solution, unfortunately. It's a little unclear to me why git prints this sequence here at all, are we expecting that there is already other text printed on the line? Or is it to clear cells that may have had another background color when the current line was scrolled in? Maybe that case is more unusual and less harmful than actually eating the final character, that it's not worth clearing?
-- Mikael Magnusson