diff options
| author | Andy Koppe <andy.koppe@gmail.com> | 2023-08-20 19:50:06 +0100 |
|---|---|---|
| committer | Junio C Hamano <gitster@pobox.com> | 2023-08-21 11:40:09 -0700 |
| commit | dcb347f83780b67ba586fda67a5c494b31354eae (patch) | |
| tree | bee602b08027ef4bc3178569c793ccfde9f38ee2 /log-tree.c | |
| parent | b87a9a2c1ef8c39d4fc3d1e28ebb79563d4804be (diff) | |
| download | git-dcb347f83780b67ba586fda67a5c494b31354eae.tar.xz | |
decorate: color each token separately
Wrap "tag:" prefixes and the arrows in "HEAD -> branch" decorations in
their own color sequences. Otherwise, if --graph is used, tag names or
arrows can end up uncolored when %w width formatting breaks a line just
before them. This is because --graph resets the color after doing its
drawing at the start of a line.
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>
Diffstat (limited to 'log-tree.c')
| -rw-r--r-- | log-tree.c | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/log-tree.c b/log-tree.c index 7c6d3f1ac3..44f4693567 100644 --- a/log-tree.c +++ b/log-tree.c @@ -342,26 +342,34 @@ void format_decorations(struct strbuf *sb, * appeared, skipping the entry for current. */ if (decoration != current_and_HEAD) { + const char *color = + decorate_get_color(use_color, decoration->type); + if (*prefix) { strbuf_addstr(sb, color_commit); 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 (decoration->type == DECORATION_REF_TAG) { + strbuf_addstr(sb, color); strbuf_addstr(sb, "tag: "); + strbuf_addstr(sb, color_reset); + } + strbuf_addstr(sb, color); show_name(sb, decoration); + strbuf_addstr(sb, color_reset); if (current_and_HEAD && decoration->type == DECORATION_REF_HEAD) { + strbuf_addstr(sb, color); strbuf_addstr(sb, " -> "); strbuf_addstr(sb, color_reset); strbuf_addstr(sb, decorate_get_color(use_color, current_and_HEAD->type)); show_name(sb, current_and_HEAD); + strbuf_addstr(sb, color_reset); } - strbuf_addstr(sb, color_reset); prefix = separator; } |
