summaryrefslogtreecommitdiff
path: root/pretty.c
diff options
context:
space:
mode:
authorRené Scharfe <rene.scharfe@lsrfire.ath.cx>2008-09-04 23:40:03 +0200
committerJunio C Hamano <gitster@pobox.com>2008-09-04 17:01:41 -0700
commit3b3d443feb1e7464c81e9a29c9b237cd6fa01fe5 (patch)
treebc49c911e298e0fe400ab00b09e0222a89217653 /pretty.c
parentcab4feb67db64d3d201145d9748b33d148f96185 (diff)
downloadgit-3b3d443feb1e7464c81e9a29c9b237cd6fa01fe5.tar.gz
add '%d' pretty format specifier to show decoration
Add a new format placeholder, %d, which expands to a ref name decoration (think git log --decorate). It expands to an empty string if the commit has no decoration, or otherwise to a comma (and space) separated list of decorations, surrounded by parentheses and a leading space. Michael Dressel implemented an initial version and chose the letter d, Junio suggested to add a leading space and parentheses. Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'pretty.c')
-rw-r--r--pretty.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/pretty.c b/pretty.c
index a29c290009..8beafa08d3 100644
--- a/pretty.c
+++ b/pretty.c
@@ -5,6 +5,7 @@
#include "revision.h"
#include "string-list.h"
#include "mailmap.h"
+#include "log-tree.h"
static char *user_format;
@@ -481,6 +482,23 @@ static void parse_commit_header(struct format_commit_context *context)
context->commit_header_parsed = 1;
}
+static void format_decoration(struct strbuf *sb, const struct commit *commit)
+{
+ struct name_decoration *d;
+ const char *prefix = " (";
+
+ load_ref_decorations();
+ d = lookup_decoration(&name_decoration, &commit->object);
+ while (d) {
+ strbuf_addstr(sb, prefix);
+ prefix = ", ";
+ strbuf_addstr(sb, d->name);
+ d = d->next;
+ }
+ if (prefix[0] == ',')
+ strbuf_addch(sb, ')');
+}
+
static size_t format_commit_item(struct strbuf *sb, const char *placeholder,
void *context)
{
@@ -573,6 +591,9 @@ static size_t format_commit_item(struct strbuf *sb, const char *placeholder,
? '<'
: '>');
return 1;
+ case 'd':
+ format_decoration(sb, commit);
+ return 1;
}
/* For the rest we have to parse the commit header. */