Re: [PATCH 2/2] ref-filter: 'contents:trailers' show error if `:` is missing
- From
Eric Sunshine <sunshine@sunshineco.com>
- Date
- Aug 19, 2020, 19:39 UTC
- Message-ID
- <CAPig+cS398dm4W5Q2DnK+bGvw0mOG3916dHPbZ=y1JNrqz1G-w@mail.gmail.com>
- In-Reply-To
- <xmqqmu2qtpxp.fsf@gitster.c.googlers.com>
On Wed, Aug 19, 2020 at 3:07 PM Junio C Hamano <gitster@pobox.com> wrote:
Show 10 quoted lines
> Junio C Hamano <gitster@pobox.com> writes:
> > "Hariom Verma via GitGitGadget" <gitgitgadget@gmail.com> writes:
> >> +static int check_format_field(const char *arg, const char *field, const char **option)
> >> +{
> >> + else if (*opt == ':') {
> >> + *option = ++opt;
> >> + return 1;
> >> + }
>
> And the helper does not have such a breakage. It looks good.One minor comment (not worth a re-roll): I personally found:
*option = ++opt;
more confusing than:
*option = opt + 1;
The `++opt` places a higher cognitive load on the reader. As a reviewer, I had to go back and carefully reread the function to see if the side-effect of `++opt` had some impact which I didn't notice on the first readthrough. The simpler `opt + 1` does not have a side-effect, thus is easier to reason about (and doesn't require me to re-study the function when I encounter it).