summaryrefslogtreecommitdiff
path: root/pretty.c
diff options
context:
space:
mode:
authorNguyễn Thái Ngọc Duy <pclouds@gmail.com>2013-04-19 09:08:43 +1000
committerJunio C Hamano <gitster@pobox.com>2013-04-18 16:28:27 -0700
commit9d3f002f21f78576f3c31ae94ce78de54e305c95 (patch)
tree8523cf6f3c1caf0167b6518b1c48072c6157e39c /pretty.c
parentd2ea4afb03d0f44284b73bbca7fd4d98168b0230 (diff)
downloadgit-9d3f002f21f78576f3c31ae94ce78de54e305c95.tar.gz
pretty: share code between format_decoration and show_decorations
This also adds color support to format_decorations() Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'pretty.c')
-rw-r--r--pretty.c20
1 files changed, 2 insertions, 18 deletions
diff --git a/pretty.c b/pretty.c
index e59688bcf5..e0f93bab0d 100644
--- a/pretty.c
+++ b/pretty.c
@@ -908,23 +908,6 @@ static void parse_commit_message(struct format_commit_context *c)
c->commit_message_parsed = 1;
}
-static void format_decoration(struct strbuf *sb, const struct commit *commit)
-{
- struct name_decoration *d;
- const char *prefix = " (";
-
- load_ref_decorations(DECORATE_SHORT_REFS);
- 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 void strbuf_wrap(struct strbuf *sb, size_t pos,
size_t width, size_t indent1, size_t indent2)
{
@@ -1103,7 +1086,8 @@ static size_t format_commit_one(struct strbuf *sb, const char *placeholder,
strbuf_addstr(sb, get_revision_mark(NULL, commit));
return 1;
case 'd':
- format_decoration(sb, commit);
+ load_ref_decorations(DECORATE_SHORT_REFS);
+ format_decorations(sb, commit, 0);
return 1;
case 'g': /* reflog info */
switch(placeholder[1]) {