summaryrefslogtreecommitdiff
path: root/pretty.c
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2017-08-15 10:25:27 (GMT)
committerJunio C Hamano <gitster@pobox.com>2017-08-15 18:13:58 (GMT)
commit58311c66fd316dff8f2c68a634ca0cf968227870 (patch)
tree64097b270164843eab9b680239a74f83a0586e45 /pretty.c
parentcc1735c4a3cf3377289640ce1af6b4c4523bee11 (diff)
downloadgit-58311c66fd316dff8f2c68a634ca0cf968227870.zip
git-58311c66fd316dff8f2c68a634ca0cf968227870.tar.gz
git-58311c66fd316dff8f2c68a634ca0cf968227870.tar.bz2
pretty: support normalization options for %(trailers)
The interpret-trailers command recently learned some options to make its output easier to parse (for a caller whose only interested in picking out the trailer values). But it's not very efficient for asking for the trailers of many commits in a single invocation. We already have "%(trailers)" to do that, but it doesn't know about unfolding or omitting non-trailers. Let's plumb those options through, so you can have the best of both. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'pretty.c')
-rw-r--r--pretty.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/pretty.c b/pretty.c
index 33054e2..0e23fe3 100644
--- a/pretty.c
+++ b/pretty.c
@@ -1044,6 +1044,7 @@ static size_t format_commit_one(struct strbuf *sb, /* in UTF-8 */
const struct commit *commit = c->commit;
const char *msg = c->message;
struct commit_list *p;
+ const char *arg;
int ch;
/* these are independent of the commit */
@@ -1262,10 +1263,18 @@ static size_t format_commit_one(struct strbuf *sb, /* in UTF-8 */
return 1;
}
- if (starts_with(placeholder, "(trailers)")) {
+ if (skip_prefix(placeholder, "(trailers", &arg)) {
struct process_trailer_options opts = PROCESS_TRAILER_OPTIONS_INIT;
- format_trailers_from_commit(sb, msg + c->subject_off, &opts);
- return strlen("(trailers)");
+ while (*arg == ':') {
+ if (skip_prefix(arg, ":only", &arg))
+ opts.only_trailers = 1;
+ else if (skip_prefix(arg, ":unfold", &arg))
+ opts.unfold = 1;
+ }
+ if (*arg == ')') {
+ format_trailers_from_commit(sb, msg + c->subject_off, &opts);
+ return arg - placeholder + 1;
+ }
}
return 0; /* unknown placeholder */