πŸš€ go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.git
Article #3183

Re: [PATCH] pretty: fix lost and leaked colors at line breaks

#3183
From: Junio C Hamano
Date: Mon, 16 Nov 2026 16:25
34 lines
14056 bytes
Andy Koppe <andy.koppe@gmail.com> writes:

> Colors in custom log formats remain in effect until reset, including
> across line breaks. Lines therefore don't necessarily set their own
> colors, nor reset them at their end, which leads to two problems.
>
> Firstly, lines that continue colors from preceding lines lose them when
> shown without that context. Notably, --graph and color-aware pagers such
> as less reset colors at line breaks, so for example "%C(bold)%w(72)%s"
> only makes the first line of a wrapped subject bold, and "%C(cyan)%b"
> only colors the first line of the message body.

And custom format writers have no way to control what happens at the
(artificial) line boundary that wrapping at 72 columns %w(72)
introduces, %b may include many lines but there is nothing for them
to say "at the end of each and every line, do this".  And that is
why you decided that runtime detection is the only way to do this to
help custom formats?

OK.  My initial reaction to the "let's do the same as the default
format output" was "isn't that the responsibility of those who write
their own custom format?", but there clearly is a gap in the custom
format feature that makes it impossible for them to do so.

> The same can happen to
> lines picked out by grepping colored output.

I am not sure if that is a problem.

> Secondly, colors that are still active at the end of a line can leak
> into what follows.

That somehow feels contradictory with the previous point, though.
Technical Details
Message-ID: <xmqq4idgn3py.fsf@gitster.g>
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!git+bounces-75548-linux-kernel-git=dewy.ru
References: <2f9f835e3f99d7de5bbf51be2e8ef4dc0485a46e.1794778250.git.andy.koppe@gmail.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!git+bounces-75548-linux-kernel-git=dewy.ru
From: gitster@pobox.com (Junio C Hamano)
Newsgroups: linux.kernel.git
Subject: Re: [PATCH] pretty: fix lost and leaked colors at line breaks
Date: Mon, 16 Nov 2026 08:25:13 -0800
Organization: Usenet Network
Message-ID: <xmqq4idgn3py.fsf@gitster.g>
References: <2f9f835e3f99d7de5bbf51be2e8ef4dc0485a46e.1794778250.git.andy.koppe@gmail.com>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Info: usenet.network;
	logging-data="2110165"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:V8W0VNEbZ5NYgs3vZx2X++HKYXw= sha256:l1urXcRFtMhfFDtr0Mu6RSCaGOKoeIe70WsKc7NWBVw=
	sha1:DF7jQJw/viVVtrom68oJMZNkTG0= sha256:evX8PZVL8Icn7JVb45U/0d2GDVaiewVMY7CWmpX+3sI=
List-ID: <git.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1])
	by mail.dewy.ru (Postfix) with ESMTP id 20013114CDB; Mon, 16 Nov 2026 19:25:43 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.05
X-Spam-Status: No, score=-3.05 tagged_above=-9999 required=6.31
	tests=[DCC_REPUT_70_89=0.1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1,
	DKIM_VALID_AU=-0.1, HEADER_FROM_DIFFERENT_DOMAINS=0.249,
	MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001,
	SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
	header.d=pobox.com header.b=WB+YQTQg; dkim=pass (2048-bit key)
	header.d=messagingengine.com header.b=gwQ/lf3L
X-Received: from mail.dewy.ru ([127.0.0.1])
	by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
	with ESMTP id Osj5v8yPS8JV;
	Mon, 16 Nov 2026 19:25:39 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=git+bounces-75548-linux-kernel-git=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=pobox.com
X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])
	by mail.dewy.ru (Postfix) with ESMTPS id 97F35114CCF; Mon, 16 Nov 2026 19:25:20 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by sea.lore.kernel.org (Postfix) with ESMTP id 7EAAB29551; Mon, 16 Nov 2026 16:25:17 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
	t=1794846317;
	b=oOepoR6u1OCuAl6XxYjqrteLbW14Aw+xv4hNeIeudHTmGmmZuEx6NHAezEiAGa13DFa0
	 2VhgdHDDz6axqMHfuwB9GhSppxYxOsa4etlj4keqpsoouONtZLYTskKGwwLjNbvGhvsvw
	 VfFyvG76CU3rF4WqUSAYKtUmROwLunS8sHYbGiyfuTHwpTldTGFZx7VM9kThGTNRiVR+i
	 gwl9LvtQ0uRgJ0qacwPWr7gWz2e+41Sk8t2/i1ZA2Isog6og5w06lDxbp0x7KhOjAcV/Q
	 qiEB4ko+n7fN0wpL28NOm8LSXvxAyxvA4rucZRPlPnbEsZH0o3O98cRN+Afz07hclvw==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1794846317;
	h=X-Original-To:Received:DMARC-Filter:Received:Received:DKIM-Signature:
	 DKIM-Signature:X-DKIM2-Info:DKIM2-Signature:X-DKIM2-Info:
	 Message-Instance:X-ME-Sender:X-ME-Received:X-ME-Proxy-Cause:
	 X-ME-Proxy:Feedback-ID:Received:From:To:Cc:Subject:In-Reply-To:
	 References:Date:Message-ID:User-Agent:X-Mailing-List:List-Id:
	 List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner:
	 Precedence:MIME-Version:Content-Type;
	bh=97MF44pDL/Dx4tn9u6seudb20pgZAL6xQYCE0aaVNvo=;
	b=EfXustP7kFYDxMhKv9SXcZA6dm4xRLFVTok+hylWVtYbP8SOI4XWArybsu4XQSCHB+2+
	 X2LLxhwkQh19ccy0W/xf/S0zIunUR1A94MHYhNei3OSiy0J+ZnA9KS9viF8CnMPocvWar
	 e1cQxsgGPtpzPmWg0QfeCF/o67ya0WgJdUL49FbUzEcYabDqm2RkFmX/XcCfgcvlzbEMJ
	 lKulURCCPbJJyQHeYLVnu0gFtiAl9F+kbgc1aewqP0m00lpMRGDTCMKpL7gEA0ZGyvM7g
	 eJHr0FE2jvSXqlJUWVYP6vXS21OTbvvxulsucSgeau4jOk6jcMYhuh1fSCYSrlLDkHg==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=pobox.com header.i=@pobox.com header.a=rsa-sha256 header.s=fm2 header.b=WB+YQTQg;
	dkim=pass header.d=messagingengine.com header.i=@messagingengine.com header.a=rsa-sha256 header.s=fm3 header.b="gwQ/lf3L";
	dmarc=pass header.from=pobox.com;
	spf=pass smtp.mailfrom=pobox.com;
	arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id 2C4DB606A32F;
	Mon, 16 Nov 2026 16:25:17 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key, unprotected) header.d=pobox.com header.i=@pobox.com header.a=rsa-sha256 header.s=fm2 header.b=WB+YQTQg;
	dkim=pass (2048-bit key, unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.a=rsa-sha256 header.s=fm3 header.b=gwQ/lf3L
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=103.168.172.153
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1794846316;
	b=yws47MSNrz7puZZ1DFSp8yofNSJADWaxcnBsZLfMsFxKn+vVXMTLLGU8+C/s1BV6XP53
	 cIs2LW2xrckBI+jv2qaYx1Q2mSDx6Zc9YNft50Rca82TwQ6FK+EldD0tDflHM+dHG2Z/p
	 WjsfToclr6aHd23PF1nghu0rgBaiPhyqruE7eXrLfCd0rNJZKxHdPGQFmxErxt879oYyJ
	 4cAlDqR2zXVNv3jMng0RZetu7+pHJEOgauWx+rjazRKYB1a9ToSUcp2OQ3PN2hdnKHY9l
	 rYrTBlxSAx1cVR1bUo9BrUTgTDr2sTduiXGfsxmWSYO9VzgxltzhO/aBe9ts564tjFA==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1794846316;
	h=DMARC-Filter:Received:Received:DKIM-Signature:DKIM-Signature:
	 X-DKIM2-Info:DKIM2-Signature:X-DKIM2-Info:Message-Instance:
	 X-ME-Sender:X-ME-Received:X-ME-Proxy-Cause:X-ME-Proxy:Feedback-ID:
	 Received:From:To:Cc:Subject:In-Reply-To:References:Date:Message-ID:
	 User-Agent:MIME-Version:Content-Type;
	bh=97MF44pDL/Dx4tn9u6seudb20pgZAL6xQYCE0aaVNvo=;
	b=a4V80FMdz8UwMfPanikCHBwKi7iDxPXBYKrwI71uyrZ8ZRQ5moMrtF9z5Uptw5lqlU7+
	 uIarK46vGYNEQBvye9GOgNqWXckttausO3LMTl3JzYApfTdU3vCZRmwrNscrPCmkBhzap
	 i8LcOcvOsAaq66wnhcVOMNVnfu8Bqx33+9nxbVI41yzp4/tdP4CkjcHj4EtM/9QTWH/uX
	 QF2AoIVMSatOOaxVdmw4n9JoYj8uNDhTc3NCkw97eFMm2NBrDqgpGCQlxUaAZhkqqb7de
	 qNtqUZlhV1eBs6plOqEcBKxMvdtTrOkqlCgm2faiDHUmpMI6XeziR1hYtxBHfCLOgiQ==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dmarc=pass header.from=pobox.com;
	spf=pass smtp.mailfrom=pobox.com;
	dkim=pass header.d=pobox.com header.i=@pobox.com header.a=rsa-sha256 header.s=fm2 header.b=WB+YQTQg;
	dkim=pass header.d=messagingengine.com header.i=@messagingengine.com header.a=rsa-sha256 header.s=fm3 header.b="gwQ/lf3L";
	arc=none smtp.remote-ip=103.168.172.153
X-Received: from fhigh-a2-smtp.messagingengine.com (fhigh-a2-smtp.messagingengine.com [103.168.172.153])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature ECDSA (prime256v1))
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id BE4D0606A322
	for <git@vger.kernel.org>; Mon, 16 Nov 2026 16:25:15 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org BE4D0606A322
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=pobox.com
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=pobox.com
X-Received: from phl-compute-02.internal (phl-compute-02.internal [10.202.2.42])
	by mailfhigh.phl.internal (Postfix) with ESMTP id F140B1400068
	for <git@vger.kernel.org>; Mon, 16 Nov 2026 11:25:14 -0500 (EST)
X-Received: from phl-frontend-02 ([10.202.2.161])
  by phl-compute-02.internal (MEProxy); Mon, 16 Nov 2026 11:25:14 -0500
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pobox.com; h=cc
	:cc:content-type:content-type:date:date:from:from:in-reply-to
	:in-reply-to:message-id:mime-version:references:reply-to:subject
	:subject:to:to; s=fm2; t=1794846314; x=1794932714; bh=97MF44pDL/
	Dx4tn9u6seudb20pgZAL6xQYCE0aaVNvo=; b=WB+YQTQgd4v2VZy+oHwZlAmwnf
	q/OGD/gcwXC2VDc/DxxwVlteKQDDSKFq+JyHqaw88+9HPNPqo/NazUAnV8kS5eYu
	/puOpwQG2jLqPXMRyeIzxWdtpWPB6GvXk7zxVBYz63v5dfkARDXJptqIPxjrVUJv
	mCmllSbbSkIoPJUHLnhv9AXItWQlZO+pb0++4rKZkYS06plLEE6U9yOq8PgwMGo8
	jsHaLmTc+66WY7QeLGfsXdw/SAlUvX8k7EQt2ITIuZ8pQmhouy0PdGLncyBfIAFJ
	djDxXArdGjSLGi9E38PSM9CkHo/Hi8gUfkA8d0faycKcmTo01gKFpqY+QHkQ==
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=
	messagingengine.com; h=cc:cc:content-type:content-type:date:date
	:feedback-id:feedback-id:from:from:in-reply-to:in-reply-to
	:message-id:mime-version:references:reply-to:subject:subject:to
	:to:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t=
	1794846314; x=1794932714; bh=97MF44pDL/Dx4tn9u6seudb20pgZAL6xQYC
	E0aaVNvo=; b=gwQ/lf3LTtLAbon9Gg6bpjW/ZZCmi3jsP+xdNpkJZQpazYpRCjO
	oXQ2bJqFy1gtnocfGiFWKxK5nxjTwz37lxzwyydFQ1Z3mhyfVobCjGFj41VuA4to
	szZVICXTgcXfl761mHD4VhbYWfDCE+iG+waIgOTb2z84qaxDSgCLs8i7UYIkocJv
	Ns935mMbg0B9BnOLmYvOT4EpflMnOWPlVZ3KztP5rSgGShW6RcWCyWKZmMxZYwDJ
	ciBwDIjXXaedJNVcdL1yEdMo3B1suowjI5Qx7wqQUUIZ7T6jeOOMWVr8wOmjw14U
	Sw1tg8GOcU4/9/NaGQYoJIcGw1DCEoY1ogg==
X-DKIM2-Info: draft=ietf-dkim-dkim2-spec-09;
	repo=github.com/dkim2wg/interop; date=2026-11-03; sw=lmtpprox;
	action=sign d=pobox.com a=rsa-sha256;
X-DKIM2-Signature: i=1; m=1; t=1794846314; d=pobox.com;
	mf=PGdpdHN0ZXJAcG9ib3guY29tPg==;
	rt=PGdpdEB2Z2VyLmtlcm5lbC5vcmc+;
	s=fm2:rsa-sha256:Jyu1fb1b2cXJDBPQiB9zyYPNuW2+3vrdga3o0m8oC8nAg1K
	epnYockKlxSolIcv2PIYW68T/VK7AMd5EHUiX8xFNTOAE/3JVC2IAvl+6G2q5/nf
	ynwKBl70mEeF5xmy3m6RlEXQHeherrmj6tWIkQAapaErxJxjecWyc8FW7nHY9Cva
	kStEXKXdIQ3gYhZaaYfeEWZi69Xq/PxT9R51Nq7Qz7zvrtNDmLc9NjEmto6dZCQW
	jRcvP0etqxLORx+cYWgM8MimSPi5cLL9oMd85YWVeq4j4xeNH//mhaN/EYhu3fkm
	jYQoSgnETmy1oTuySjLVcOYGskuW37UrJafignQ==;
X-DKIM2-Info: draft=ietf-dkim-dkim2-spec-09;
	repo=github.com/dkim2wg/interop; date=2026-11-03; sw=lmtpprox;
	action=mi-m=1; hc=12;
	hn=cc,content-type,date,feedback-id,from,in-reply-to,message-id,
	mime-version,references,subject,to,user-agent;
X-Message-Instance: m=1; h=sha256:i4/Bi7cKEDwZbRFJAigK5ELyvVKjAP+Dz3y/GE1oxB0=:ZKBmfwrMZyeTmzVtuZRkcdUg3VoDLaqIhxwgT5jnT0I=;
X-ME-Sender: <xms:ai77avXU7i7HiC5T_ZvL6dze69-9sR0nrNWJwX-UNfuEJtsFNoLj9g>
    <xme:ai77auewDXLI99MVrEjEvBo7Ti9cLSpfok7q43PzqLcl0CiLzs-Iv3_m69T1R7Jsp
    mVeemDPon-rO1YhAbnievdM7S7tCxvxwDMtY6pfvmvd5FLsbT_9vw>
X-ME-Received: <xmr:ai77ajtvyuZV6lusfQFq30n9D1X8Ao0Y3coW8Cg-0exopuddzDhlbxkhiZmKXp0WQod5bfXsQETCJzG04WoMQikueMwBuEAbeHmU>
X-ME-Proxy-Cause: dmFkZTE1XEanc75WZ8gaXkkZTfPMNDyvmuMOjgDCWOR+LDvsydid6l3YPheWhsU5+OCs6p
    GtGLg/TvFXFTaZ3mGbxYTKfwDa2EojJtu6QlZYhthK1xWxzYNIFBGebf4DuTyIs2vZynXD
    qawVfwNtM0JztxXZwQ8cWs41GJKmE7NCwE5sMLDfKxjl0axF7sRfjIRw1JHPmAUzS2mb8f
    GnGNCBcEUKD12uGcxh55gXAEz5OiupdbCrOsdNOUmnDCX87YUwu0k+9zgzqkAFOAIn2rVT
    Poo64LIsYo8WqlOfvJm8mtgzXAgA9nPi4sULb71U+3kt7o1oPlH1fg7QNs1hL3IhCkqTcM
    h/tkT93LxuPPA7LQDO8fCQG7OPcRAPrK2CIs4h9sWZLSa5Ky7ZfDn37dq6KGKBy0+ZjlV6
    tNT7VzpPOniFdBWx3urTe/glelbE/EBIBQfjhrxeskCkFTe/jrGZpSJ7F8tDWeN46Yvt4t
    KQk+Xk69q7z+ZJ9Mz4xDzQBrUm2e+XMqp76hCljhEsFZJvk3vRKTWXHFfzqxF0AuKNnbjT
    71XIERA+8nv8LO5vR8OJ/7gKnCSJTUXIOejQ9kpKEoUJGMIu5KQzOxA8Zaj6YbXhwPNJUZ
    PhiCReEVpY3O7m0sipSmtiNw8CDdW8XlbdEJNd/0Q9cxnNob9n9KG29NPhgg
X-ME-Proxy: <xmx:ai77al-IJV6-eYhgB87ZNEIMuRH29m3qu06CGajSVPto67N25glzRw>
    <xmx:ai77am0nKh0RFi-LnJRmMMF3-cI554EqUp6KYAC0Mi8BaROMIVIEtw>
    <xmx:ai77aiAR1yyif5OszSdtbeJUfidYzCICj6qk8gDUgSJ02VG9hUQVsQ>
    <xmx:ai77aqdSrjCg05dhMzKkpK6P_iarefqtqqi_j1s_ZesIPAL1hXxXRA>
    <xmx:ai77aobG7y2pLjTta6HuNgF6PNwM0goiwx_CIB9TYzNJhCZyAv1mMMN8>
X-Feedback-ID: if26b431b:Fastmail
X-Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon,
 16 Nov 2026 11:25:14 -0500 (EST)
X-Cc: git@vger.kernel.org,  Jeff King <peff@peff.net>,  RenΓ©
 Scharfe
 <l.s.r@web.de>
X-In-Reply-To: <2f9f835e3f99d7de5bbf51be2e8ef4dc0485a46e.1794778250.git.andy.koppe@gmail.com>
	(Andy Koppe's message of "Sun, 15 Nov 2026 21:35:03 +0000")
X-User-Agent: Gnus/5.13 (Gnus v5.13)
X-Mailing-List: git@vger.kernel.org
X-List-Post: <mailto:git@vger.kernel.org>
X-List-Help: <mailto:git+help@vger.kernel.org>
X-List-Subscribe: <mailto:git+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:git+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:git+owner@vger.kernel.org>
X-Precedence: list