git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Jeff King <peff@peff.net>
To: Duy Nguyen <pclouds@gmail.com>
Cc: Junio C Hamano <gitster@pobox.com>, git@vger.kernel.org
Subject: [PATCH] document behavior of empty color name
Date: Thu, 2 Feb 2017 13:42:44 +0100	[thread overview]
Message-ID: <20170202124238.53k74cedpp2rcmzo@sigill.intra.peff.net> (raw)
In-Reply-To: <20170202091615.GA22337@ash>

On Thu, Feb 02, 2017 at 04:16:15PM +0700, Duy Nguyen wrote:

> > I hadn't heard anything back,
> 
> Sorry I was accidentally busy during Luna new year holiday.

No problem. That sounds much more fun than working on Git. :)

> > -	if (!len)
> > -		return -1;
> > +	if (!len) {
> > +		dst[0] = '\0';
> > +		return 0;
> > +	}
> >  
> >  	if (!strncasecmp(ptr, "reset", len)) {
> >  		xsnprintf(dst, end - dst, GIT_COLOR_RESET);
> 
> I wonder if it makes more sense to do this in builtin/config.c. The
> "default value" business is strictly git-config command's. The parsing
> function does not need to know. Maybe something like this?

I don't think so. The default value is a git-config thing, but you would
want to be able to do the same thing in a config file. For example, to
disable coloring entirely for part of the diff, you could do:

  [color "diff"]
  meta = ""

> This is also a good opportunity to document this behavior in
> git-config.txt, I think.

Yeah. Maybe:

-- >8 --
Subject: [PATCH] document behavior of empty color name

Commit 55cccf4bb (color_parse_mem: allow empty color spec,
2017-02-01) clearly defined the behavior of an empty color
config variable. Let's document that, and give a hint about
why it might be useful.

It's important not to say that it makes the item uncolored,
because it doesn't. It just sets no attributes, which means
that any previous attributes continue to take effect.

Signed-off-by: Jeff King <peff@peff.net>
---
 Documentation/config.txt | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/Documentation/config.txt b/Documentation/config.txt
index 33a007b52..49b264566 100644
--- a/Documentation/config.txt
+++ b/Documentation/config.txt
@@ -170,6 +170,9 @@ The position of any attributes with respect to the colors
 be turned off by prefixing them with `no` or `no-` (e.g., `noreverse`,
 `no-ul`, etc).
 +
+An empty color string produces no color effect at all. This can be used
+to avoid coloring specific elements without disabling color entirely.
++
 For git's pre-defined color slots, the attributes are meant to be reset
 at the beginning of each item in the colored output. So setting
 `color.decorate.branch` to `black` will paint that branch name in a
-- 
2.11.0.948.gca97da533


  reply	other threads:[~2017-02-02 12:42 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-31 22:45 What's cooking in git.git (Jan 2017, #06; Tue, 31) Junio C Hamano
2017-02-01  0:21 ` [PATCH] color_parse_mem: allow empty color spec Jeff King
2017-02-01  1:19   ` Jacob Keller
2017-02-02  9:16   ` Duy Nguyen
2017-02-02 12:42     ` Jeff King [this message]
2017-02-03  9:24       ` [PATCH] document behavior of empty color name Duy Nguyen
2017-02-03 12:29         ` Jeff King
2017-02-03 18:12           ` Junio C Hamano
2017-02-04  0:49             ` Jeff King
2017-02-01 11:08 ` What's cooking in git.git (Jan 2017, #06; Tue, 31) Patrick Steinhardt
2017-02-01 18:40   ` Junio C Hamano

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

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170202124238.53k74cedpp2rcmzo@sigill.intra.peff.net \
    --to=peff@peff.net \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=pclouds@gmail.com \
    /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.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).