summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--pretty.c17
-rw-r--r--pretty.h3
2 files changed, 15 insertions, 5 deletions
diff --git a/pretty.c b/pretty.c
index 59cefdddf6..ed16b32df9 100644
--- a/pretty.c
+++ b/pretty.c
@@ -1152,12 +1152,16 @@ int format_set_trailers_options(struct process_trailer_options *opts,
struct string_list *filter_list,
struct strbuf *sepbuf,
struct strbuf *kvsepbuf,
- const char **arg)
+ const char **arg,
+ char **invalid_arg)
{
for (;;) {
const char *argval;
size_t arglen;
+ if (**arg == ')')
+ break;
+
if (match_placeholder_arg_value(*arg, "key", arg, &argval, &arglen)) {
uintptr_t len = arglen;
@@ -1190,8 +1194,13 @@ int format_set_trailers_options(struct process_trailer_options *opts,
} else if (!match_placeholder_bool_arg(*arg, "only", arg, &opts->only_trailers) &&
!match_placeholder_bool_arg(*arg, "unfold", arg, &opts->unfold) &&
!match_placeholder_bool_arg(*arg, "keyonly", arg, &opts->key_only) &&
- !match_placeholder_bool_arg(*arg, "valueonly", arg, &opts->value_only))
- break;
+ !match_placeholder_bool_arg(*arg, "valueonly", arg, &opts->value_only)) {
+ if (invalid_arg) {
+ size_t len = strcspn(*arg, ",)");
+ *invalid_arg = xstrndup(*arg, len);
+ }
+ return -1;
+ }
}
return 0;
}
@@ -1473,7 +1482,7 @@ static size_t format_commit_one(struct strbuf *sb, /* in UTF-8 */
if (*arg == ':') {
arg++;
- if (format_set_trailers_options(&opts, &filter_list, &sepbuf, &kvsepbuf, &arg))
+ if (format_set_trailers_options(&opts, &filter_list, &sepbuf, &kvsepbuf, &arg, NULL))
goto trailer_out;
}
if (*arg == ')') {
diff --git a/pretty.h b/pretty.h
index 7369cf7e14..d902cdd70a 100644
--- a/pretty.h
+++ b/pretty.h
@@ -151,6 +151,7 @@ int format_set_trailers_options(struct process_trailer_options *opts,
struct string_list *filter_list,
struct strbuf *sepbuf,
struct strbuf *kvsepbuf,
- const char **arg);
+ const char **arg,
+ char **invalid_arg);
#endif /* PRETTY_H */