@matheusbsbs / matheus-bagliano / commits / 5e11bee65f
Fork 0

Allow customizable commit decorations colors

Signed-off-by: Nazri Ramliy <ayiehere@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Nazri Ramliy committed Jun 24, 2010 at 08:21 UTC 5e11bee65f601ba97dc4c61c75fcb2f448fdcb1c
4 files changed +45
Documentation/config.txt
+5
@@ -683,6 +683,11 @@ color.diff.<slot>::
683 (highlighting whitespace errors). The values of these variables may be
684 specified as in color.branch.<slot>.
685
686 +color.decorate.<slot>::
687 + Use customized color for 'git log --decorate' output. `<slot>` is one
688 + of `branch`, `remoteBranch`, `tag`, `stash` or `HEAD` for local
689 + branches, remote tracking branches, tags, stash and HEAD, respectively.
690 +
691 color.grep::
692 When set to `always`, always highlight matches. When `false` (or
693 `never`), never. When set to `true` or `auto`, use color only
builtin/log.c
+3
@@ -296,6 +296,9 @@ static int git_log_config(const char *var, const char *value, void *cb)
296 default_show_root = git_config_bool(var, value);
297 return 0;
298 }
299 + if (!prefixcmp(var, "color.decorate."))
300 + return parse_decorate_color_config(var, 15, value);
301 +
302 return git_diff_ui_config(var, value, cb);
303 }
304
log-tree.c
+36
@@ -36,6 +36,42 @@ static const char *decorate_get_color(int decorate_use_color, enum decoration_ty
36 return "";
37 }
38
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 +
75 /*
76 * log-tree.c uses DIFF_OPT_TST for determining whether to use color
77 * for showing the commit sha1, use the same check for --decorate
log-tree.h
+1
@@ -7,6 +7,7 @@ struct log_info {
7 struct commit *commit, *parent;
8 };
9
10 +int parse_decorate_color_config(const char *var, const int ofs, const char *value);
11 void init_log_tree_opt(struct rev_info *);
12 int log_tree_diff_flush(struct rev_info *);
13 int log_tree_commit(struct rev_info *, struct commit *);