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

[PATCH 4/4] Allow customizable coloring of commit decorations

From
Nazri Ramliy <ayiehere@gmail.com>
Date
Jun 19, 2010, 01:37 UTC
Message-ID
<1276911456-18466-4-git-send-email-ayiehere@gmail.com>
In-Reply-To
<7vtyp11k9x.fsf@alter.siamese.dyndns.org>
Signed-off-by: Nazri Ramliy <ayiehere@gmail.com>
---
 Documentation/config.txt |    6 ++++++
 builtin/log.c            |    3 +++
 log-tree.c               |   24 ++++++++++++++++++++++++
 log-tree.h               |    1 +
 4 files changed, 34 insertions(+), 0 deletions(-)
diff --git a/Documentation/config.txt b/Documentation/config.txt
index 95cf73c..b3e80c1 100644
--- a/Documentation/config.txt
+++ b/Documentation/config.txt
@@ -683,6 +683,12 @@ color.diff.<slot>::
 	(highlighting whitespace errors). The values of these variables may be
 	specified as in color.branch.<slot>.
 
+color.decorate.<slot>::
+	Use customized color for 'git log --decorate' output.
+	`<slot>` is one of `reflocal`, `refremote`, `reftag`, `refstash` or
+	`refhead` for local refs, remote refs, tags, stash and HEAD,
+	respectively.
+
 color.grep::
 	When set to `always`, always highlight matches.  When `false` (or
 	`never`), never.  When set to `true` or `auto`, use color only
diff --git a/builtin/log.c b/builtin/log.c
index 976e16f..0835866 100644
--- a/builtin/log.c
+++ b/builtin/log.c
@@ -296,6 +296,9 @@ static int git_log_config(const char *var, const char *value, void *cb)
 		default_show_root = git_config_bool(var, value);
 		return 0;
 	}
+	if (!prefixcmp(var, "color.decorate."))
+		return parse_decorate_color_config(var, 15, value);
+
 	return git_diff_ui_config(var, value, cb);
 }
 
diff --git a/log-tree.c b/log-tree.c
index 25586cf..0265228 100644
--- a/log-tree.c
+++ b/log-tree.c
@@ -36,6 +36,30 @@ static const char *decorate_get_color(int decorate_use_color, enum decoration_ty
 	return "";
 }
 
+static int parse_decorate_color_slot(const char *slot) {
+	if (!strcasecmp(slot, "reflocal"))
+		return DECORATION_REF_LOCAL;
+	if (!strcasecmp(slot, "refremote"))
+		return DECORATION_REF_REMOTE;
+	if (!strcasecmp(slot, "reftag"))
+		return DECORATION_REF_TAG;
+	if (!strcasecmp(slot, "refstash"))
+		return DECORATION_REF_STASH;
+	if (!strcasecmp(slot, "refhead"))
+		return DECORATION_REF_HEAD;
+	return -1;
+}
+
+int parse_decorate_color_config(const char *var, const int ofs, const char *value) {
+	int slot = parse_decorate_color_slot(var + ofs);
+	if (slot < 0)
+		return 0;
+	if (!value)
+		return config_error_nonbool(var);
+	color_parse(value, var, decoration_colors[slot]);
+	return 0;
+}
+
 /*
  * log-tree.c uses DIFF_OPT_TST for determining whether to use color
  * for showing the commit sha1, use the same check for --decorate
diff --git a/log-tree.h b/log-tree.h
index 3f7b400..5c4cf7c 100644
--- a/log-tree.h
+++ b/log-tree.h
@@ -7,6 +7,7 @@ struct log_info {
 	struct commit *commit, *parent;
 };
 
+int parse_decorate_color_config(const char *var, const int ofs, const char *value);
 void init_log_tree_opt(struct rev_info *);
 int log_tree_diff_flush(struct rev_info *);
 int log_tree_commit(struct rev_info *, struct commit *);
-- 
1.7.1.245.g7c42e.dirty
Previous: Nazri Ramliy
Message 9 of 9 in “Colorize commit decorations”
  1. Colorize commit decorationsNazri Ramliy, Jun 17, 2010
  2. Junio C HamanoJun 17, 2010
  3. 1/4 commit.h: add 'type' to struct name_decorationNazri Ramliy, Jun 19, 2010
  4. Junio C HamanoJun 22, 2010
  5. Allow customizable commit decorations colorsNazri Ramliy, Jun 23, 2010
  6. Allow customizable commit decorations colorsNazri Ramliy, Jun 24, 2010
  7. 2/4 log-tree.c: Use struct name_decoration's type for classifying decorationNazri Ramliy, Jun 19, 2010
  8. 3/4 log --decorate: Colorize commit decorationsNazri Ramliy, Jun 19, 2010
  9. 4/4 Allow customizable coloring of commit decorationsNazri Ramliy, Jun 19, 2010

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.