summaryrefslogtreecommitdiff
path: root/log-tree.c
diff options
context:
space:
mode:
authorNazri Ramliy <ayiehere@gmail.com>2010-06-24 08:21:16 +0800
committerJunio C Hamano <gitster@pobox.com>2010-06-24 12:57:34 -0700
commit5e11bee65f601ba97dc4c61c75fcb2f448fdcb1c (patch)
treee9a6767dfbaeec64b96843c74f4315d8d9220770 /log-tree.c
parent67a4b5864f9423ccfe8090365029dae918504830 (diff)
downloadgit-5e11bee65f601ba97dc4c61c75fcb2f448fdcb1c.tar.gz
Allow customizable commit decorations colors
Signed-off-by: Nazri Ramliy <ayiehere@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'log-tree.c')
-rw-r--r--log-tree.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/log-tree.c b/log-tree.c
index 61680f4664..b46ed3baef 100644
--- a/log-tree.c
+++ b/log-tree.c
@@ -36,6 +36,42 @@ static const char *decorate_get_color(int decorate_use_color, enum decoration_ty
return "";
}
+static int parse_decorate_color_slot(const char *slot)
+{
+ /*
+ * We're comparing with 'ignore-case' on
+ * (because config.c sets them all tolower),
+ * but let's match the letters in the literal
+ * string values here with how they are
+ * documented in Documentation/config.txt, for
+ * consistency.
+ *
+ * We love being consistent, don't we?
+ */
+ if (!strcasecmp(slot, "branch"))
+ return DECORATION_REF_LOCAL;
+ if (!strcasecmp(slot, "remoteBranch"))
+ return DECORATION_REF_REMOTE;
+ if (!strcasecmp(slot, "tag"))
+ return DECORATION_REF_TAG;
+ if (!strcasecmp(slot, "stash"))
+ return DECORATION_REF_STASH;
+ if (!strcasecmp(slot, "HEAD"))
+ 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