From: Edward Thomson <ethomson@edwardthomson.com>
To: git@vger.kernel.org
Subject: [PATCH] format_commit_message: honor `color=auto` for `%C(auto)`
Date: Tue, 24 May 2016 14:48:14 -0500 [thread overview]
Message-ID: <20160524194814.GA12479@zoidberg> (raw)
Check that we are configured to display colors in the given context when
the user specifies a format string of `%C(auto)`, instead of always
displaying the default color for the given context. This makes
`%C(auto)` obey the `color=auto` setting and brings its behavior in line
with the behavior of `%C(auto,<colorname>)`.
This allows the user the ability to specify that color should be
displayed for a string only when the output is a tty, and to use the
default color for the given context without having to hardcode a
color value.
---
pretty.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/pretty.c b/pretty.c
index 87c4497..c3ec430 100644
--- a/pretty.c
+++ b/pretty.c
@@ -1063,7 +1063,7 @@ static size_t format_commit_one(struct strbuf *sb, /* in UTF-8 */
switch (placeholder[0]) {
case 'C':
if (starts_with(placeholder + 1, "(auto)")) {
- c->auto_color = 1;
+ c->auto_color = want_color(c->pretty_ctx->color);
return 7; /* consumed 7 bytes, "C(auto)" */
} else {
int ret = parse_color(sb, placeholder, c);
--
2.6.4 (Apple Git-63)
next reply other threads:[~2016-05-24 20:05 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-05-24 19:48 Edward Thomson [this message]
2016-05-25 0:55 ` [PATCH] format_commit_message: honor `color=auto` for `%C(auto)` Junio C Hamano
2016-05-25 1:26 ` Edward Thomson
-- strict thread matches above, loose matches on Subject: below --
2016-05-25 1:56 Edward Thomson
2016-05-25 22:39 ` Jeff King
2016-05-27 3:47 ` Edward Thomson
2016-05-31 12:23 ` Duy Nguyen
2016-05-31 22:18 ` Jeff King
2016-05-27 3:46 Edward Thomson
2016-05-27 3:55 ` Jeff King
2016-05-27 6:22 ` 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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20160524194814.GA12479@zoidberg \
--to=ethomson@edwardthomson.com \
--cc=git@vger.kernel.org \
/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;
as well as URLs for NNTP newsgroup(s).