summaryrefslogtreecommitdiff
path: root/pretty.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2010-04-18 21:31:29 -0700
committerJunio C Hamano <gitster@pobox.com>2010-04-18 21:31:29 -0700
commit779f9467ebcd345e60118db89e2c0a4b38204607 (patch)
treebaa2358b904b55580ab4f07488ebcd16051775e5 /pretty.c
parentfab45027e0cdf3ebdade137cb3740604da7bb4bc (diff)
parent636db2c036d0f26bd0b1139b7abe04bdecf3e036 (diff)
downloadgit-779f9467ebcd345e60118db89e2c0a4b38204607.tar.gz
Merge branch 'jg/auto-initialize-notes-with-percent-n-in-format'
* jg/auto-initialize-notes-with-percent-n-in-format: t3301: add tests to use --format="%N" pretty: Initialize notes if %N is used
Diffstat (limited to 'pretty.c')
-rw-r--r--pretty.c40
1 files changed, 36 insertions, 4 deletions
diff --git a/pretty.c b/pretty.c
index 6ba3da89b7..7cb3a2af50 100644
--- a/pretty.c
+++ b/pretty.c
@@ -775,10 +775,13 @@ static size_t format_commit_one(struct strbuf *sb, const char *placeholder,
}
return 0; /* unknown %g placeholder */
case 'N':
- format_display_notes(commit->object.sha1, 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. */
@@ -855,6 +858,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)