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

[PATCH] format_commit_message: honor `color=auto` for `%C(auto)`

From
Edward Thomson <ethomson@edwardthomson.com>
Date
May 25, 2016, 01:56 UTC
Message-ID
<20160525015649.GA13258@zoidberg>

Check that we are configured to display colors in the given context when the user specifies a format string of `%C(auto)`. This brings that behavior in line with the behavior of `%C(auto,<colorname>)`, which will display the given color only when the configuration specifies to do so.

This allows the user the ability to specify that color should be displayed only when the output is a tty, and to use the default color for the given context (instead of a hardcoded color value).

Signed-off-by: Edward Thomson <ethomson@edwardthomson.com>
---
 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: Jeff King
Message 1 of 5 in “format_commit_message: honor `color=auto` for `%C(auto)`”
  1. format_commit_message: honor `color=auto` for `%C(auto)`Edward Thomson, May 25, 2016
  2. Jeff KingMay 25, 2016
  3. Edward ThomsonMay 27, 2016
  4. Duy NguyenMay 31, 2016
  5. Jeff KingMay 31, 2016

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.