summaryrefslogtreecommitdiff
path: root/pretty.c
diff options
context:
space:
mode:
Diffstat (limited to 'pretty.c')
-rw-r--r--pretty.c54
1 files changed, 46 insertions, 8 deletions
diff --git a/pretty.c b/pretty.c
index d493cad..74cda1b 100644
--- a/pretty.c
+++ b/pretty.c
@@ -716,7 +716,7 @@ static size_t format_commit_one(struct strbuf *sb, const char *placeholder,
if (add_again(sb, &c->abbrev_commit_hash))
return 1;
strbuf_addstr(sb, find_unique_abbrev(commit->object.sha1,
- DEFAULT_ABBREV));
+ c->pretty_ctx->abbrev));
c->abbrev_commit_hash.len = sb->len - c->abbrev_commit_hash.off;
return 1;
case 'T': /* tree hash */
@@ -726,7 +726,7 @@ static size_t format_commit_one(struct strbuf *sb, const char *placeholder,
if (add_again(sb, &c->abbrev_tree_hash))
return 1;
strbuf_addstr(sb, find_unique_abbrev(commit->tree->object.sha1,
- DEFAULT_ABBREV));
+ c->pretty_ctx->abbrev));
c->abbrev_tree_hash.len = sb->len - c->abbrev_tree_hash.off;
return 1;
case 'P': /* parent hashes */
@@ -743,7 +743,8 @@ static size_t format_commit_one(struct strbuf *sb, const char *placeholder,
if (p != commit->parents)
strbuf_addch(sb, ' ');
strbuf_addstr(sb, find_unique_abbrev(
- p->item->object.sha1, DEFAULT_ABBREV));
+ p->item->object.sha1,
+ c->pretty_ctx->abbrev));
}
c->abbrev_parent_hashes.len = sb->len -
c->abbrev_parent_hashes.off;
@@ -775,9 +776,13 @@ static size_t format_commit_one(struct strbuf *sb, const char *placeholder,
}
return 0; /* unknown %g placeholder */
case 'N':
- get_commit_notes(commit, sb, git_log_output_encoding ?
- git_log_output_encoding : git_commit_encoding, 0);
- return 1;
+ if (c->pretty_ctx->show_notes) {
+ format_display_notes(commit->object.sha1, sb,
+ git_log_output_encoding ? git_log_output_encoding
+ : git_commit_encoding, 0);
+ return 1;
+ }
+ return 0;
}
/* For the rest we have to parse the commit header. */
@@ -796,6 +801,10 @@ static size_t format_commit_one(struct strbuf *sb, const char *placeholder,
case 'e': /* encoding */
strbuf_add(sb, msg + c->encoding.off, c->encoding.len);
return 1;
+ case 'B': /* raw body */
+ /* message_off is always left at the initial newline */
+ strbuf_addstr(sb, msg + c->message_off + 1);
+ return 1;
}
/* Now we need to parse the commit message. */
@@ -854,6 +863,35 @@ static size_t format_commit_item(struct strbuf *sb, const char *placeholder,
return consumed + 1;
}
+static size_t userformat_want_item(struct strbuf *sb, const char *placeholder,
+ void *context)
+{
+ struct userformat_want *w = context;
+
+ if (*placeholder == '+' || *placeholder == '-')
+ placeholder++;
+
+ switch (*placeholder) {
+ case 'N':
+ w->notes = 1;
+ break;
+ }
+ return 0;
+}
+
+void userformat_find_requirements(const char *fmt, struct userformat_want *w)
+{
+ struct strbuf dummy = STRBUF_INIT;
+
+ if (!fmt) {
+ if (!user_format)
+ return;
+ fmt = user_format;
+ }
+ strbuf_expand(&dummy, user_format, userformat_want_item, w);
+ strbuf_release(&dummy);
+}
+
void format_commit_message(const struct commit *commit,
const char *format, struct strbuf *sb,
const struct pretty_print_context *pretty_ctx)
@@ -1095,8 +1133,8 @@ void pretty_print_commit(enum cmit_fmt fmt, const struct commit *commit,
strbuf_addch(sb, '\n');
if (context->show_notes)
- get_commit_notes(commit, sb, encoding,
- NOTES_SHOW_HEADER | NOTES_INDENT);
+ format_display_notes(commit->object.sha1, sb, encoding,
+ NOTES_SHOW_HEADER | NOTES_INDENT);
free(reencoded);
}