Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndy Koppe <andy.koppe@gmail.com>2023-08-20 21:50:08 +0300
committerJunio C Hamano <gitster@pobox.com>2023-08-21 21:40:10 +0300
commitf1f8a258567268974b9bbd012c33ad219a31aa0e (patch)
treebcd9ee55e4bb42eff9a588313bef32193d15cf5e /log-tree.c
parenta58dd835e9536cf9e7adcd404d008a44d29af804 (diff)
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.c12
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);