log: add color.decorate.ref config variable
Refs other than branches, remote-tracking branches, tags and the stash do not appear in log decorations by default, but they can be shown by using decoration filter options such as --clear-decorations or log.initialDecorationSet. However, they would appear without color. Add config variable color.decorate.ref for such refs, defaulting to bold magenta, which is the same as refs/stash. Document the new variable on the git-config page and amend t4207-log-decoration-colors.sh to test it. Signed-off-by: Andy Koppe <andy.koppe@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:

committed by
Junio C Hamano

parent
5a446c38a7
commit
c6bcc49d69
@ -90,11 +90,16 @@ color.decorate.<slot>::
|
|||||||
lightweight and annotated tags
|
lightweight and annotated tags
|
||||||
`stash`;;
|
`stash`;;
|
||||||
the stash ref
|
the stash ref
|
||||||
|
`ref`;;
|
||||||
|
any other refs (not shown by default)
|
||||||
`grafted`;;
|
`grafted`;;
|
||||||
grafted and replaced commits
|
grafted and replaced commits
|
||||||
`symbol`;;
|
`symbol`;;
|
||||||
punctuation symbols surrounding the other elements
|
punctuation symbols surrounding the other elements
|
||||||
--
|
--
|
||||||
|
+
|
||||||
|
(Variable `log.initialDecorationSet` or linkgit:git-log[1] option
|
||||||
|
`--clear-decorations` can be used to show all refs.)
|
||||||
|
|
||||||
color.grep::
|
color.grep::
|
||||||
When set to `always`, always highlight matches. When `false` (or
|
When set to `always`, always highlight matches. When `false` (or
|
||||||
|
1
commit.h
1
commit.h
@ -54,6 +54,7 @@ enum decoration_type {
|
|||||||
DECORATION_REF_REMOTE,
|
DECORATION_REF_REMOTE,
|
||||||
DECORATION_REF_TAG,
|
DECORATION_REF_TAG,
|
||||||
DECORATION_REF_STASH,
|
DECORATION_REF_STASH,
|
||||||
|
DECORATION_REF,
|
||||||
DECORATION_REF_HEAD,
|
DECORATION_REF_HEAD,
|
||||||
DECORATION_GRAFTED,
|
DECORATION_GRAFTED,
|
||||||
DECORATION_SYMBOL,
|
DECORATION_SYMBOL,
|
||||||
|
@ -39,6 +39,7 @@ static char decoration_colors[][COLOR_MAXLEN] = {
|
|||||||
[DECORATION_REF_REMOTE] = GIT_COLOR_BOLD_RED,
|
[DECORATION_REF_REMOTE] = GIT_COLOR_BOLD_RED,
|
||||||
[DECORATION_REF_TAG] = GIT_COLOR_BOLD_YELLOW,
|
[DECORATION_REF_TAG] = GIT_COLOR_BOLD_YELLOW,
|
||||||
[DECORATION_REF_STASH] = GIT_COLOR_BOLD_MAGENTA,
|
[DECORATION_REF_STASH] = GIT_COLOR_BOLD_MAGENTA,
|
||||||
|
[DECORATION_REF] = GIT_COLOR_BOLD_MAGENTA,
|
||||||
[DECORATION_REF_HEAD] = GIT_COLOR_BOLD_CYAN,
|
[DECORATION_REF_HEAD] = GIT_COLOR_BOLD_CYAN,
|
||||||
[DECORATION_GRAFTED] = GIT_COLOR_BOLD_BLUE,
|
[DECORATION_GRAFTED] = GIT_COLOR_BOLD_BLUE,
|
||||||
[DECORATION_SYMBOL] = GIT_COLOR_NIL,
|
[DECORATION_SYMBOL] = GIT_COLOR_NIL,
|
||||||
@ -49,6 +50,7 @@ static const char *color_decorate_slots[] = {
|
|||||||
[DECORATION_REF_REMOTE] = "remoteBranch",
|
[DECORATION_REF_REMOTE] = "remoteBranch",
|
||||||
[DECORATION_REF_TAG] = "tag",
|
[DECORATION_REF_TAG] = "tag",
|
||||||
[DECORATION_REF_STASH] = "stash",
|
[DECORATION_REF_STASH] = "stash",
|
||||||
|
[DECORATION_REF] = "ref",
|
||||||
[DECORATION_REF_HEAD] = "HEAD",
|
[DECORATION_REF_HEAD] = "HEAD",
|
||||||
[DECORATION_GRAFTED] = "grafted",
|
[DECORATION_GRAFTED] = "grafted",
|
||||||
[DECORATION_SYMBOL] = "symbol",
|
[DECORATION_SYMBOL] = "symbol",
|
||||||
@ -151,7 +153,7 @@ static int add_ref_decoration(const char *refname, const struct object_id *oid,
|
|||||||
int i;
|
int i;
|
||||||
struct object *obj;
|
struct object *obj;
|
||||||
enum object_type objtype;
|
enum object_type objtype;
|
||||||
enum decoration_type deco_type = DECORATION_NONE;
|
enum decoration_type deco_type = DECORATION_REF;
|
||||||
struct decoration_filter *filter = (struct decoration_filter *)cb_data;
|
struct decoration_filter *filter = (struct decoration_filter *)cb_data;
|
||||||
const char *git_replace_ref_base = ref_namespace[NAMESPACE_REPLACE].ref;
|
const char *git_replace_ref_base = ref_namespace[NAMESPACE_REPLACE].ref;
|
||||||
|
|
||||||
|
@ -17,6 +17,7 @@ test_expect_success setup '
|
|||||||
git config color.decorate.remoteBranch red &&
|
git config color.decorate.remoteBranch red &&
|
||||||
git config color.decorate.tag "reverse bold yellow" &&
|
git config color.decorate.tag "reverse bold yellow" &&
|
||||||
git config color.decorate.stash magenta &&
|
git config color.decorate.stash magenta &&
|
||||||
|
git config color.decorate.ref blue &&
|
||||||
git config color.decorate.grafted black &&
|
git config color.decorate.grafted black &&
|
||||||
git config color.decorate.symbol white &&
|
git config color.decorate.symbol white &&
|
||||||
git config color.decorate.HEAD cyan &&
|
git config color.decorate.HEAD cyan &&
|
||||||
@ -28,11 +29,13 @@ test_expect_success setup '
|
|||||||
c_remoteBranch="<RED>" &&
|
c_remoteBranch="<RED>" &&
|
||||||
c_tag="<BOLD;REVERSE;YELLOW>" &&
|
c_tag="<BOLD;REVERSE;YELLOW>" &&
|
||||||
c_stash="<MAGENTA>" &&
|
c_stash="<MAGENTA>" &&
|
||||||
|
c_ref="<BLUE>" &&
|
||||||
c_HEAD="<CYAN>" &&
|
c_HEAD="<CYAN>" &&
|
||||||
c_grafted="<BLACK>" &&
|
c_grafted="<BLACK>" &&
|
||||||
c_symbol="<WHITE>" &&
|
c_symbol="<WHITE>" &&
|
||||||
|
|
||||||
test_commit A &&
|
test_commit A &&
|
||||||
|
git update-ref refs/foo A &&
|
||||||
git clone . other &&
|
git clone . other &&
|
||||||
(
|
(
|
||||||
cd other &&
|
cd other &&
|
||||||
@ -65,10 +68,12 @@ ${c_remoteBranch}other/main${c_reset}${c_symbol})${c_reset} A1
|
|||||||
${c_commit}COMMIT_ID${c_reset}${c_symbol} (${c_reset}\
|
${c_commit}COMMIT_ID${c_reset}${c_symbol} (${c_reset}\
|
||||||
${c_stash}refs/stash${c_reset}${c_symbol})${c_reset} On main: Changes to A.t
|
${c_stash}refs/stash${c_reset}${c_symbol})${c_reset} On main: Changes to A.t
|
||||||
${c_commit}COMMIT_ID${c_reset}${c_symbol} (${c_reset}\
|
${c_commit}COMMIT_ID${c_reset}${c_symbol} (${c_reset}\
|
||||||
${c_tag}tag: ${c_reset}${c_tag}A${c_reset}${c_symbol})${c_reset} A
|
${c_tag}tag: ${c_reset}${c_tag}A${c_reset}${c_symbol}, ${c_reset}\
|
||||||
|
${c_ref}refs/foo${c_reset}${c_symbol})${c_reset} A
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
git log --first-parent --no-abbrev --decorate --oneline --color=always --all >actual &&
|
git log --first-parent --no-abbrev --decorate --clear-decorations \
|
||||||
|
--oneline --color=always --all >actual &&
|
||||||
cmp_filtered_decorations
|
cmp_filtered_decorations
|
||||||
'
|
'
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user