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

Re: [PATCH] sideband: allow ANSI SGR with colon-separated subfields

From
Junio C Hamano <gitster@pobox.com>
Date
Jul 7, 2026, 18:19 UTC
Message-ID
<xmqq4iia4q8t.fsf@gitster.g>
In-Reply-To
<8addf7c0-ae39-f1c0-20ab-52114702aaf6@gmx.de>
Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:
Show 16 quoted lines
> Hi Mantas,
>
> On Wed, 13 May 2026, grawity@nullroute.lt wrote:
>
>> From: Mantas Mikulėnas <grawity@gmail.com>
>> 
>> The SGR values used for 256-color formatting are officially defined to
>> be a single field with :-separated subfields (e.g. "\e[1;38:5:XX;40m")
>> despite the more common but kludgy use of separate values (which then
>> become context-dependent and lead to misinterpretation by incompatible
>> terminals).
>> 
>> See also: https://github.com/ThomasDickey/xterm-snapshots/blob/6380a3eaed857c182ea6cfa78cd706966b2628d0/charproc.c#L2047-L2118
>
> This change seems well-motivated and well-executed to me. Just in case
> anybody was waiting for my objections, there ain't any coming ;-)
Should I take it as an Ack?

FWIW, this patch literally flew below my radar coverage. Thanks for noticing.

A need for fix-up like this does makes me doubt out decision to go with whitelisting very narrow cases that are known to be OK (and finding that the cases were too narrow and we need to extend), instead of rejecting known-bad cases, by the way.

Thanks.
Show 37 quoted lines
> Ciao,
> Johannes
>
>> 
>> Signed-off-by: Mantas Mikulėnas <grawity@gmail.com>
>> ---
>>  sideband.c | 6 +++++-
>>  1 file changed, 5 insertions(+), 1 deletion(-)
>> 
>> diff --git a/sideband.c b/sideband.c
>> index 04282a568e..6cf70ef6f6 100644
>> --- a/sideband.c
>> +++ b/sideband.c
>> @@ -163,6 +163,10 @@ static int handle_ansi_sequence(struct strbuf *dest, const char *src, int n)
>>  	 *
>>  	 * ESC [ [<n> [; <n>]*] m
>>  	 *
>> +	 * where <n> can be either zero-length, or a decimal number, or a
>> +	 * series of decimal numbers separated by a colon (for 256-color or
>> +	 * true-color codes).
>> +	 *
>>  	 * These are part of the Select Graphic Rendition sequences which
>>  	 * contain more than just color sequences, for more details see
>>  	 * https://en.wikipedia.org/wiki/ANSI_escape_code#SGR.
>> @@ -210,7 +214,7 @@ static int handle_ansi_sequence(struct strbuf *dest, const char *src, int n)
>>  			strbuf_add(dest, src, i + 1);
>>  			return i;
>>  		}
>> -		if (!isdigit(src[i]) && src[i] != ';')
>> +		if (!isdigit(src[i]) && src[i] != ':' && src[i] != ';')
>>  			break;
>>  	}
>>  
>> -- 
>> 2.54.0
>> 
>> 
Previous: Johannes SchindelinNext: Mantas
Message 3 of 4 in “sideband: allow ANSI SGR with colon-separated subfields”
  1. sideband: allow ANSI SGR with colon-separated subfieldsgrawity@nullroute.lt, May 13, 2026
  2. Johannes SchindelinJul 7, 2026
  3. Junio C HamanoJul 7, 2026
  4. MantasJul 7, 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.