Re: [PATCH 3/5] ref-filter.c: add trailer options to used_atom
- From
Jeff King <peff@peff.net>
- Date
- Sep 30, 2017, 07:10 UTC
- Message-ID
- <20170930071057.3mosgarb5coje4pu@sigill.intra.peff.net>
- In-Reply-To
- <20170930062238.87077-4-me@ttaylorr.com>
On Fri, Sep 29, 2017 at 11:22:36PM -0700, Taylor Blau wrote:
Show 6 quoted lines
> In preparation for "%(trailers)" to take trailer parsing arguments, use Jeff's > convenience structure for trailer processing options introduced in 8abc89800c. > > We will later populate this field from the arguments given to %(trailers), and > then use the trailer_opts instance to format ref trailers correctly using > `format_trailer_from_commit`.
I think this should probably just be squashed in with the next patch, since this does nothing at all without adding a caller that uses it.
Show 11 quoted lines
> diff --git a/ref-filter.c b/ref-filter.c
> index 467c0279c..84f14093c 100644
> --- a/ref-filter.c
> +++ b/ref-filter.c
> @@ -82,6 +82,7 @@ static struct used_atom {
> } remote_ref;
> struct {
> enum { C_BARE, C_BODY, C_BODY_DEP, C_LINES, C_SIG, C_SUB, C_TRAILERS } option;
> + struct process_trailer_options trailer_opts;
> unsigned int nlines;
> } contents;This contents struct is odd. The used_atom struct can have many types, and has has a big union of type-specific data. And then we break down the "contents" type with a further enum, but don't actually put the type-specific data into a union (not just your patch, but already "nlines" is specific only to C_LINES).
It's probably not worth caring about, though. The point of a union is to reduce the overall struct size, and here our type-specific data is fairly small. It would only change the overall struct size if it were larger than other parts of the union (and remote_ref, for example, is pretty big).
-Peff
PS As an aside, I find the whole %(contents:...) thing a bit unfortunate. I understand why the _implementation_ wants to group similar options together so that it can avoid parsing too much. But the user doesn't care about that. Just "%(trailers)" should be sufficient (as evidenced by the fact that we added it a separate alias). But none of that is new to your series.