Re: [PATCH] ref-filter: add new atom "signature" atom
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Jan 3, 2023, 00:58 UTC
- Message-ID
- <xmqqv8lov3hh.fsf@gitster.g>
- In-Reply-To
- <CAP8UFD3i7C2c79V2ORxh-Q-rNuwKVqkMRX0VoXy3iugw=u5K+A@mail.gmail.com>
Christian Couder <christian.couder@gmail.com> writes:
Show 7 quoted lines
>> I am not sure I have understood this, which helper? > > I think Junio is talking about the following function: > > static enum signature_option parse_signature_option(const char *arg) > > he suggested above.
Correct.
> With this function the above code could be just something like: > > if (parse_signature_option(name) < 0) > continue;
More or less so, but the first "if" in the helper I wrote in the message above is broken. It should be
static enum signature_option parse_signature_option(const char *arg)
{
if (!*arg)
return S_BARE;
else if (!strcmp(arg, "signer"))
return S_SIGNER;
...
else
return -1;
}and then the code equivalent to the bunch of strcmp() would be
if (skip_prefix(name, "signature", &name) &&
(!*name || *name++ == ':') &&
(0 <= parse_signature_option(name)))
; /* we have "signature"-related atom */
else
continue; /* not a "signature" atom */or something like that.