From: Andy Koppe <andy.koppe@gmail.com>
To: git@vger.kernel.org
Cc: pclouds@gmail.com, Andy Koppe <andy.koppe@gmail.com>
Subject: [PATCH] log: omit tag prefix for color decoration
Date: Sun, 19 Feb 2023 17:46:30 +0000 [thread overview]
Message-ID: <20230219174631.1040-1-andy.koppe@gmail.com> (raw)
Omit the "tag: " prefix for tags in commit decorations when coloring is
enabled. The prefix isn't necessary as such when tags are distinguished
by color already, and omitting it saves a bit of space and visual noise.
It also avoids a problem: when the %d or %D placeholders are used while
a %w wrapping specifier is in force in a format string, lines can be
broken between the prefix and the tag name. In that case, the prefix
gets colored correctly, but the tag name gets the default color instead.
Also remove the tag prefix from test t4207 for color decorations, and
add --no-color to a test t6002 check of the output of rev-list --bisect
that expects tag prefixes to be present.
Signed-off-by: Andy Koppe <andy.koppe@gmail.com>
---
CI run: https://github.com/ak2/git/actions/runs/4211957381
log-tree.c | 3 ++-
t/t4207-log-decoration-colors.sh | 22 +++++++++++-----------
t/t6002-rev-list-bisect.sh | 2 +-
3 files changed, 14 insertions(+), 13 deletions(-)
diff --git a/log-tree.c b/log-tree.c
index 1dd5fcbf7b..64ea15e0a0 100644
--- a/log-tree.c
+++ b/log-tree.c
@@ -324,7 +324,8 @@ void format_decorations_extended(struct strbuf *sb,
strbuf_addstr(sb, prefix);
strbuf_addstr(sb, color_reset);
strbuf_addstr(sb, decorate_get_color(use_color, decoration->type));
- if (decoration->type == DECORATION_REF_TAG)
+ if (!use_color &&
+ decoration->type == DECORATION_REF_TAG)
strbuf_addstr(sb, "tag: ");
show_name(sb, decoration);
diff --git a/t/t4207-log-decoration-colors.sh b/t/t4207-log-decoration-colors.sh
index ded33a82e2..a5ee7b19d7 100755
--- a/t/t4207-log-decoration-colors.sh
+++ b/t/t4207-log-decoration-colors.sh
@@ -55,13 +55,13 @@ test_expect_success 'commit decorations colored correctly' '
cat >expect <<-EOF &&
${c_commit}COMMIT_ID${c_reset}${c_commit} (${c_reset}${c_HEAD}HEAD -> \
${c_reset}${c_branch}main${c_reset}${c_commit}, \
-${c_reset}${c_tag}tag: v1.0${c_reset}${c_commit}, \
-${c_reset}${c_tag}tag: B${c_reset}${c_commit})${c_reset} B
-${c_commit}COMMIT_ID${c_reset}${c_commit} (${c_reset}${c_tag}tag: A1${c_reset}${c_commit}, \
+${c_reset}${c_tag}v1.0${c_reset}${c_commit}, \
+${c_reset}${c_tag}B${c_reset}${c_commit})${c_reset} B
+${c_commit}COMMIT_ID${c_reset}${c_commit} (${c_reset}${c_tag}A1${c_reset}${c_commit}, \
${c_reset}${c_remoteBranch}other/main${c_reset}${c_commit})${c_reset} A1
${c_commit}COMMIT_ID${c_reset}${c_commit} (${c_reset}${c_stash}refs/stash${c_reset}${c_commit})${c_reset} \
On main: Changes to A.t
- ${c_commit}COMMIT_ID${c_reset}${c_commit} (${c_reset}${c_tag}tag: A${c_reset}${c_commit})${c_reset} A
+ ${c_commit}COMMIT_ID${c_reset}${c_commit} (${c_reset}${c_tag}A${c_reset}${c_commit})${c_reset} A
EOF
git log --first-parent --no-abbrev --decorate --oneline --color=always --all >actual &&
@@ -78,10 +78,10 @@ test_expect_success 'test coloring with replace-objects' '
cat >expect <<-EOF &&
${c_commit}COMMIT_ID${c_reset}${c_commit} (${c_reset}${c_HEAD}HEAD -> \
${c_reset}${c_branch}main${c_reset}${c_commit}, \
-${c_reset}${c_tag}tag: D${c_reset}${c_commit})${c_reset} D
- ${c_commit}COMMIT_ID${c_reset}${c_commit} (${c_reset}${c_tag}tag: C${c_reset}${c_commit}, \
+${c_reset}${c_tag}D${c_reset}${c_commit})${c_reset} D
+ ${c_commit}COMMIT_ID${c_reset}${c_commit} (${c_reset}${c_tag}C${c_reset}${c_commit}, \
${c_reset}${c_grafted}replaced${c_reset}${c_commit})${c_reset} B
- ${c_commit}COMMIT_ID${c_reset}${c_commit} (${c_reset}${c_tag}tag: A${c_reset}${c_commit})${c_reset} A
+ ${c_commit}COMMIT_ID${c_reset}${c_commit} (${c_reset}${c_tag}A${c_reset}${c_commit})${c_reset} A
EOF
git log --first-parent --no-abbrev --decorate --oneline --color=always HEAD >actual &&
@@ -102,11 +102,11 @@ test_expect_success 'test coloring with grafted commit' '
cat >expect <<-EOF &&
${c_commit}COMMIT_ID${c_reset}${c_commit} (${c_reset}${c_HEAD}HEAD -> \
${c_reset}${c_branch}main${c_reset}${c_commit}, \
-${c_reset}${c_tag}tag: D${c_reset}${c_commit}, \
+${c_reset}${c_tag}D${c_reset}${c_commit}, \
${c_reset}${c_grafted}replaced${c_reset}${c_commit})${c_reset} D
- ${c_commit}COMMIT_ID${c_reset}${c_commit} (${c_reset}${c_tag}tag: v1.0${c_reset}${c_commit}, \
-${c_reset}${c_tag}tag: B${c_reset}${c_commit})${c_reset} B
- ${c_commit}COMMIT_ID${c_reset}${c_commit} (${c_reset}${c_tag}tag: A${c_reset}${c_commit})${c_reset} A
+ ${c_commit}COMMIT_ID${c_reset}${c_commit} (${c_reset}${c_tag}v1.0${c_reset}${c_commit}, \
+${c_reset}${c_tag}B${c_reset}${c_commit})${c_reset} B
+ ${c_commit}COMMIT_ID${c_reset}${c_commit} (${c_reset}${c_tag}A${c_reset}${c_commit})${c_reset} A
EOF
git log --first-parent --no-abbrev --decorate --oneline --color=always HEAD >actual &&
diff --git a/t/t6002-rev-list-bisect.sh b/t/t6002-rev-list-bisect.sh
index 162cf50778..924923afaa 100755
--- a/t/t6002-rev-list-bisect.sh
+++ b/t/t6002-rev-list-bisect.sh
@@ -305,7 +305,7 @@ test_expect_success '--bisect-all --first-parent' '
# expect results to be ordered by distance (descending),
# commit hash (ascending)
sort -k4,4r -k1,1 expect.unsorted >expect &&
- git rev-list --bisect-all --first-parent E ^F >actual &&
+ git rev-list --bisect-all --first-parent --no-color E ^F >actual &&
test_cmp expect actual
'
--
2.39.0
next reply other threads:[~2023-02-19 17:50 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-19 17:46 Andy Koppe [this message]
2023-02-20 21:36 ` [PATCH] log: omit tag prefix for color decoration Junio C Hamano
2023-02-21 21:28 ` Andy Koppe
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230219174631.1040-1-andy.koppe@gmail.com \
--to=andy.koppe@gmail.com \
--cc=git@vger.kernel.org \
--cc=pclouds@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).