diff options
author | Taylor Blau <me@ttaylorr.com> | 2017-10-01 18:18:47 +0200 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2017-10-02 02:22:52 +0200 |
commit | 84ff053d47c20c9f417f857e4adac0bcd8e01f0d (patch) | |
tree | 8d46824980c9d3082724658a22f999bc41409317 /pretty.c | |
parent | The eleventh batch for 2.15 (diff) | |
download | git-84ff053d47c20c9f417f857e4adac0bcd8e01f0d.tar.xz git-84ff053d47c20c9f417f857e4adac0bcd8e01f0d.zip |
pretty.c: delimit "%(trailers)" arguments with ","
In preparation for adding consistent "%(trailers)" atom options to
`git-for-each-ref(1)`'s "--format" argument, change "%(trailers)" in
pretty.c to separate sub-arguments with a ",", instead of a ":".
Multiple sub-arguments are given either as "%(trailers:unfold,only)" or
"%(trailers:only,unfold)".
This change disambiguates between "top-level" arguments, and arguments
given to the trailers atom itself. It is consistent with the behavior of
"%(upstream)" and "%(push)" atoms.
Signed-off-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'pretty.c')
-rw-r--r-- | pretty.c | 33 |
1 files changed, 28 insertions, 5 deletions
@@ -1056,6 +1056,24 @@ static size_t parse_padding_placeholder(struct strbuf *sb, return 0; } +static int match_placeholder_arg(const char *to_parse, const char *candidate, + const char **end) +{ + const char *p; + + if (!(skip_prefix(to_parse, candidate, &p))) + return 0; + if (*p == ',') { + *end = p + 1; + return 1; + } + if (*p == ')') { + *end = p; + return 1; + } + return 0; +} + static size_t format_commit_one(struct strbuf *sb, /* in UTF-8 */ const char *placeholder, void *context) @@ -1285,11 +1303,16 @@ static size_t format_commit_one(struct strbuf *sb, /* in UTF-8 */ if (skip_prefix(placeholder, "(trailers", &arg)) { struct process_trailer_options opts = PROCESS_TRAILER_OPTIONS_INIT; - while (*arg == ':') { - if (skip_prefix(arg, ":only", &arg)) - opts.only_trailers = 1; - else if (skip_prefix(arg, ":unfold", &arg)) - opts.unfold = 1; + if (*arg == ':') { + arg++; + for (;;) { + if (match_placeholder_arg(arg, "only", &arg)) + opts.only_trailers = 1; + else if (match_placeholder_arg(arg, "unfold", &arg)) + opts.unfold = 1; + else + break; + } } if (*arg == ')') { format_trailers_from_commit(sb, msg + c->subject_off, &opts); |