diff options
author | Andy Koppe <andy.koppe@gmail.com> | 2023-08-20 20:50:08 +0200 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2023-08-21 20:40:10 +0200 |
commit | f1f8a258567268974b9bbd012c33ad219a31aa0e (patch) | |
tree | bcd9ee55e4bb42eff9a588313bef32193d15cf5e /log-tree.c | |
parent | pretty: add %(decorate[:<options>]) format (diff) | |
download | git-f1f8a258567268974b9bbd012c33ad219a31aa0e.tar.xz git-f1f8a258567268974b9bbd012c33ad219a31aa0e.zip |
pretty: add pointer and tag options to %(decorate)
Add pointer and tag options to %(decorate) format, to allow to override
the " -> " string used to show where HEAD points and the "tag: " string
used to mark tags.
Document in pretty-formats.txt and test in t4205-log-pretty-formats.sh.
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 | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/log-tree.c b/log-tree.c index 44f4693567..50b4850eda 100644 --- a/log-tree.c +++ b/log-tree.c @@ -317,6 +317,8 @@ void format_decorations(struct strbuf *sb, const char *prefix = " ("; const char *suffix = ")"; const char *separator = ", "; + const char *pointer = " -> "; + const char *tag = "tag: "; decoration = get_name_decoration(&commit->object); if (!decoration) @@ -329,6 +331,10 @@ void format_decorations(struct strbuf *sb, suffix = opts->suffix; if (opts->separator) separator = opts->separator; + if (opts->pointer) + pointer = opts->pointer; + if (opts->tag) + tag = opts->tag; } color_commit = diff_get_color(use_color, DIFF_COMMIT); @@ -351,9 +357,9 @@ void format_decorations(struct strbuf *sb, strbuf_addstr(sb, color_reset); } - if (decoration->type == DECORATION_REF_TAG) { + if (*tag && decoration->type == DECORATION_REF_TAG) { strbuf_addstr(sb, color); - strbuf_addstr(sb, "tag: "); + strbuf_addstr(sb, tag); strbuf_addstr(sb, color_reset); } @@ -364,7 +370,7 @@ void format_decorations(struct strbuf *sb, if (current_and_HEAD && decoration->type == DECORATION_REF_HEAD) { strbuf_addstr(sb, color); - strbuf_addstr(sb, " -> "); + strbuf_addstr(sb, pointer); strbuf_addstr(sb, color_reset); strbuf_addstr(sb, decorate_get_color(use_color, current_and_HEAD->type)); show_name(sb, current_and_HEAD); |