Allow customizable commit decorations colors
Signed-off-by: Nazri Ramliy <ayiehere@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
67a4b5864f
commit
5e11bee65f
@ -683,6 +683,11 @@ color.diff.<slot>::
|
|||||||
(highlighting whitespace errors). The values of these variables may be
|
(highlighting whitespace errors). The values of these variables may be
|
||||||
specified as in color.branch.<slot>.
|
specified as in color.branch.<slot>.
|
||||||
|
|
||||||
|
color.decorate.<slot>::
|
||||||
|
Use customized color for 'git log --decorate' output. `<slot>` is one
|
||||||
|
of `branch`, `remoteBranch`, `tag`, `stash` or `HEAD` for local
|
||||||
|
branches, remote tracking branches, tags, stash and HEAD, respectively.
|
||||||
|
|
||||||
color.grep::
|
color.grep::
|
||||||
When set to `always`, always highlight matches. When `false` (or
|
When set to `always`, always highlight matches. When `false` (or
|
||||||
`never`), never. When set to `true` or `auto`, use color only
|
`never`), never. When set to `true` or `auto`, use color only
|
||||||
|
@ -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);
|
default_show_root = git_config_bool(var, value);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
if (!prefixcmp(var, "color.decorate."))
|
||||||
|
return parse_decorate_color_config(var, 15, value);
|
||||||
|
|
||||||
return git_diff_ui_config(var, value, cb);
|
return git_diff_ui_config(var, value, cb);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
36
log-tree.c
36
log-tree.c
@ -36,6 +36,42 @@ static const char *decorate_get_color(int decorate_use_color, enum decoration_ty
|
|||||||
return "";
|
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
|
* log-tree.c uses DIFF_OPT_TST for determining whether to use color
|
||||||
* for showing the commit sha1, use the same check for --decorate
|
* for showing the commit sha1, use the same check for --decorate
|
||||||
|
@ -7,6 +7,7 @@ struct log_info {
|
|||||||
struct commit *commit, *parent;
|
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 *);
|
void init_log_tree_opt(struct rev_info *);
|
||||||
int log_tree_diff_flush(struct rev_info *);
|
int log_tree_diff_flush(struct rev_info *);
|
||||||
int log_tree_commit(struct rev_info *, struct commit *);
|
int log_tree_commit(struct rev_info *, struct commit *);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user