decorate: use commit color for HEAD arrow
Use the commit color instead of the HEAD color for the arrow or custom symbol in "HEAD -> branch" decorations, for visual consistency with the prefix, separator and suffix symbols, which are also colored with the commit color. This change was triggered by the possibility that one could choose to use the same symbol for the pointer and the separator options in %(decorate), in which case they ought to be the same color. A related precedent is 'ls -l', where the arrow for symlinks gets the default color rather than that of the symlink name. Amend test t4207-log-decoration-colors.sh accordingly. Signed-off-by: Andy Koppe <andy.koppe@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Andy Koppe committed
Aug 20, 2023 at 19:50 UTC
1e63b34a449afd650b02ab19501e8ccf0c15816e
2 files changed
+4
-4
log-tree.c
+1
-1
@@ -369,7 +369,7 @@ void format_decorations(struct strbuf *sb,
369
370
if (current_and_HEAD &&
371
decoration->type == DECORATION_REF_HEAD) {
372
- strbuf_addstr(sb, color);
372
+ strbuf_addstr(sb, color_commit);
373
strbuf_addstr(sb, pointer);
374
strbuf_addstr(sb, color_reset);
375
strbuf_addstr(sb, decorate_get_color(use_color, current_and_HEAD->type));
t/t4207-log-decoration-colors.sh
+3
-3
@@ -54,7 +54,7 @@ cmp_filtered_decorations () {
54
test_expect_success 'commit decorations colored correctly' '
55
cat >expect <<-EOF &&
56
${c_commit}COMMIT_ID${c_reset}${c_commit} (${c_reset}${c_HEAD}HEAD${c_reset}\
57
-${c_HEAD} -> ${c_reset}${c_branch}main${c_reset}${c_commit}, \
57
+${c_commit} -> ${c_reset}${c_branch}main${c_reset}${c_commit}, \
58
${c_reset}${c_tag}tag: ${c_reset}${c_tag}v1.0${c_reset}${c_commit}, \
59
${c_reset}${c_tag}tag: ${c_reset}${c_tag}B${c_reset}${c_commit})${c_reset} B
60
${c_commit}COMMIT_ID${c_reset}${c_commit} (${c_reset}\
@@ -79,7 +79,7 @@ test_expect_success 'test coloring with replace-objects' '
79
80
cat >expect <<-EOF &&
81
${c_commit}COMMIT_ID${c_reset}${c_commit} (${c_reset}${c_HEAD}HEAD${c_reset}\
82
-${c_HEAD} -> ${c_reset}${c_branch}main${c_reset}${c_commit}, \
82
+${c_commit} -> ${c_reset}${c_branch}main${c_reset}${c_commit}, \
83
${c_reset}${c_tag}tag: ${c_reset}${c_tag}D${c_reset}${c_commit})${c_reset} D
84
${c_commit}COMMIT_ID${c_reset}${c_commit} (${c_reset}\
85
${c_tag}tag: ${c_reset}${c_tag}C${c_reset}${c_commit}, \
@@ -105,7 +105,7 @@ test_expect_success 'test coloring with grafted commit' '
105
106
cat >expect <<-EOF &&
107
${c_commit}COMMIT_ID${c_reset}${c_commit} (${c_reset}${c_HEAD}HEAD${c_reset}\
108
-${c_HEAD} -> ${c_reset}${c_branch}main${c_reset}${c_commit}, \
108
+${c_commit} -> ${c_reset}${c_branch}main${c_reset}${c_commit}, \
109
${c_reset}${c_tag}tag: ${c_reset}${c_tag}D${c_reset}${c_commit}, \
110
${c_reset}${c_grafted}replaced${c_reset}${c_commit})${c_reset} D
111
${c_commit}COMMIT_ID${c_reset}${c_commit} (${c_reset}\