ref-filter.c: parse trailers arguments with %(contents) atom
The %(contents) atom takes a contents "field" as its argument. Since "trailers" is one of those fields, extend contents_atom_parser to parse "trailers"'s arguments when used through "%(contents)", like: %(contents:trailers:unfold,only) A caveat: trailers_atom_parser expects NULL when no arguments are given (see: `parse_ref_filter_atom`). This is because string_list_split (given a maxsplit of -1) returns a 1-ary string_list* containing the given string if the delimiter could not be found using `strchr`. To simulate this behavior without teaching trailers_atom_parser to accept strings with length zero, conditionally pass NULL to trailers_atom_parser if the arguments portion of the argument to %(contents) is empty. Signed-off-by: Taylor Blau <me@ttaylorr.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:

committed by
Junio C Hamano

parent
67a20a0010
commit
7a5edbdb74
@ -212,9 +212,10 @@ static void contents_atom_parser(const struct ref_format *format, struct used_at
|
||||
atom->u.contents.option = C_SIG;
|
||||
else if (!strcmp(arg, "subject"))
|
||||
atom->u.contents.option = C_SUB;
|
||||
else if (!strcmp(arg, "trailers"))
|
||||
atom->u.contents.option = C_TRAILERS;
|
||||
else if (skip_prefix(arg, "lines=", &arg)) {
|
||||
else if (skip_prefix(arg, "trailers", &arg)) {
|
||||
skip_prefix(arg, ":", &arg);
|
||||
trailers_atom_parser(format, atom, *arg ? arg : NULL);
|
||||
} else if (skip_prefix(arg, "lines=", &arg)) {
|
||||
atom->u.contents.option = C_LINES;
|
||||
if (strtoul_ui(arg, 10, &atom->u.contents.nlines))
|
||||
die(_("positive value expected contents:lines=%s"), arg);
|
||||
|
Reference in New Issue
Block a user