@@ -92,6 +92,9 @@ color.decorate.<slot>::
the stash ref
`grafted`;;
grafted commits (used to implement shallow clones)
+`ref`;;
+ any other refs (not shown unless enabled with one of the decoration
+ filter options such as `--decorate-refs=<pattern>`)
`symbol`;;
punctuation surrounding the other elements
--
@@ -54,6 +54,7 @@ enum decoration_type {
DECORATION_REF_REMOTE,
DECORATION_REF_TAG,
DECORATION_REF_STASH,
+ DECORATION_REF,
DECORATION_REF_HEAD,
DECORATION_GRAFTED,
DECORATION_SYMBOL,
@@ -39,6 +39,7 @@ static char decoration_colors[][COLOR_MAXLEN] = {
[DECORATION_REF_REMOTE] = GIT_COLOR_BOLD_RED,
[DECORATION_REF_TAG] = GIT_COLOR_BOLD_YELLOW,
[DECORATION_REF_STASH] = GIT_COLOR_BOLD_MAGENTA,
+ [DECORATION_REF] = GIT_COLOR_BOLD_MAGENTA,
[DECORATION_REF_HEAD] = GIT_COLOR_BOLD_CYAN,
[DECORATION_GRAFTED] = GIT_COLOR_BOLD_BLUE,
[DECORATION_SYMBOL] = GIT_COLOR_NIL,
@@ -49,6 +50,7 @@ static const char *color_decorate_slots[] = {
[DECORATION_REF_REMOTE] = "remoteBranch",
[DECORATION_REF_TAG] = "tag",
[DECORATION_REF_STASH] = "stash",
+ [DECORATION_REF] = "ref",
[DECORATION_REF_HEAD] = "HEAD",
[DECORATION_GRAFTED] = "grafted",
[DECORATION_SYMBOL] = "symbol",
@@ -142,6 +142,13 @@ struct ref_namespace_info ref_namespace[] = {
*/
.ref = "refs/rewritten/",
},
+ [NAMESPACE_REFS] = {
+ /*
+ * Catch-all for any other refs.
+ */
+ .ref = "refs/",
+ .decoration = DECORATION_REF,
+ },
};
void update_ref_namespace(enum ref_namespace namespace, char *ref)
@@ -1008,6 +1008,7 @@ enum ref_namespace {
NAMESPACE_NOTES,
NAMESPACE_PREFETCH,
NAMESPACE_REWRITTEN,
+ NAMESPACE_REFS,
/* Must be last */
NAMESPACE__COUNT
@@ -17,6 +17,7 @@ test_expect_success setup '
git config color.decorate.remoteBranch red &&
git config color.decorate.tag "reverse bold yellow" &&
git config color.decorate.stash magenta &&
+ git config color.decorate.ref blue &&
git config color.decorate.grafted black &&
git config color.decorate.symbol white &&
git config color.decorate.HEAD cyan &&
@@ -28,11 +29,13 @@ test_expect_success setup '
c_remoteBranch="<RED>" &&
c_tag="<BOLD;REVERSE;YELLOW>" &&
c_stash="<MAGENTA>" &&
+ c_ref="<BLUE>" &&
c_HEAD="<CYAN>" &&
c_grafted="<BLACK>" &&
c_symbol="<WHITE>" &&
test_commit A &&
+ git update-ref refs/foo A &&
git clone . 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_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_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
- 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
'
Refs other than those with builtin special meaning do not appear in log decorations by default, but they can be made to appear using the decoration filter options. However, they would do so without coloring. Add config option color.decorate.ref to address this, defaulting to bold magenta, which is the same as refs/stash. To implement this, add NAMESPACE_REF with pattern "refs/", but do not set its .include bit, so as to leave it out of the default decoration filter. Document the color.decorate slot on the git-config page and amend t4207-log-decoration-colors.sh to test it. Signed-off-by: Andy Koppe <andy.koppe@gmail.com> --- Documentation/config/color.txt | 3 +++ commit.h | 1 + log-tree.c | 2 ++ refs.c | 7 +++++++ refs.h | 1 + t/t4207-log-decoration-colors.sh | 9 +++++++-- 6 files changed, 21 insertions(+), 2 deletions(-)