@@ -36,6 +36,42 @@ static const char *decorate_get_color(int decorate_use_color, enum decoration_ty
3636 return "" ;
3737}
3838
39+ static int parse_decorate_color_slot (const char * slot )
40+ {
41+ /*
42+ * We're comparing with 'ignore-case' on
43+ * (because config.c sets them all tolower),
44+ * but let's match the letters in the literal
45+ * string values here with how they are
46+ * documented in Documentation/config.txt, for
47+ * consistency.
48+ *
49+ * We love being consistent, don't we?
50+ */
51+ if (!strcasecmp (slot , "branch" ))
52+ return DECORATION_REF_LOCAL ;
53+ if (!strcasecmp (slot , "remoteBranch" ))
54+ return DECORATION_REF_REMOTE ;
55+ if (!strcasecmp (slot , "tag" ))
56+ return DECORATION_REF_TAG ;
57+ if (!strcasecmp (slot , "stash" ))
58+ return DECORATION_REF_STASH ;
59+ if (!strcasecmp (slot , "HEAD" ))
60+ return DECORATION_REF_HEAD ;
61+ return -1 ;
62+ }
63+
64+ int parse_decorate_color_config (const char * var , const int ofs , const char * value )
65+ {
66+ int slot = parse_decorate_color_slot (var + ofs );
67+ if (slot < 0 )
68+ return 0 ;
69+ if (!value )
70+ return config_error_nonbool (var );
71+ color_parse (value , var , decoration_colors [slot ]);
72+ return 0 ;
73+ }
74+
3975/*
4076 * log-tree.c uses DIFF_OPT_TST for determining whether to use color
4177 * for showing the commit sha1, use the same check for --decorate
0 commit comments