summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: cab4feb)
raw | patch | inline | side by side (parent: cab4feb)
author | René Scharfe <rene.scharfe@lsrfire.ath.cx> | |
Thu, 4 Sep 2008 21:40:03 +0000 (23:40 +0200) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Fri, 5 Sep 2008 00:01:41 +0000 (17:01 -0700) |
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>
(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>
Documentation/pretty-formats.txt | patch | blob | history | |
pretty.c | patch | blob | history |
index 388d4925e6bc4bacb708f75437e9aaa216fcb9cc..f18d33e00b7166104a200fbeaa854fb911273931 100644 (file)
- '%cr': committer date, relative
- '%ct': committer date, UNIX timestamp
- '%ci': committer date, ISO 8601 format
+- '%d': ref names, like the --decorate option of linkgit:git-log[1]
- '%e': encoding
- '%s': subject
- '%b': body
diff --git a/pretty.c b/pretty.c
index a29c290009587a12cdc6aec335d508d29481e697..8beafa08d3927e943a94279f5d776d6a45c673c5 100644 (file)
--- a/pretty.c
+++ b/pretty.c
#include "revision.h"
#include "string-list.h"
#include "mailmap.h"
+#include "log-tree.h"
static char *user_format;
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)
{
? '<'
: '>');
return 1;
+ case 'd':
+ format_decoration(sb, commit);
+ return 1;
}
/* For the rest we have to parse the commit header. */