git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] ref-filter: add new atom "signature" atom

From
Christian Couder <christian.couder@gmail.com>
Date
Jan 2, 2023, 08:37 UTC
Message-ID
<CAP8UFD3i7C2c79V2ORxh-Q-rNuwKVqkMRX0VoXy3iugw=u5K+A@mail.gmail.com>
In-Reply-To
<CA+PPyiGPRztaLsty5LqT-7GfjPusyt=7hi22z1aPdm-G8pZpuQ@mail.gmail.com>

On Mon, Jan 2, 2023 at 6:01 AM NSENGIYUMVA WILBERFORCE <nsengiyumvawilberforce@gmail.com> wrote:

Show 26 quoted lines
> > Handing the !arg case first will make the if/else if/... cascade
> > easier to follow, no?  Also the body of the function may want to
> > become a separate function that returns one of these S_FOO constants.
> >
> >         static enum signatore_option signature_atom_parser(...)
> >         {
> >                 enum signature_option opt = parse_signature_option(arg);
> >                 if (opt < 0)
> >                         return strbuf_addf_ret(err, opt, _("unknown ..."), arg);
> >                 return opt;
> >         }
> >
> > where parse_signature_option() would look like
> >
> >         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;
> >         }
> >
> > or something like that?
[...]
Show 13 quoted lines
> > > +             if (strcmp(name, "signature") &&
> > > +                     strcmp(name, "signature:signer") &&
> > > +                     strcmp(name, "signature:grade") &&
> > > +                     strcmp(name, "signature:key") &&
> > > +                     strcmp(name, "signature:fingerprint") &&
> > > +                     strcmp(name, "signature:primarykeyfingerprint") &&
> > > +                     strcmp(name, "signature:trustlevel"))
> > > +                     continue;
> >
> > And with the helper above, we can avoid the repetition here that can
> > go out of sync with the parser function.
>
> 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.
With this function the above code could be just something like:
if (parse_signature_option(name) < 0)
                    continue;
Previous: NSENGIYUMVA WILBERFORCENext: Junio C Hamano
Message 4 of 19 in “ref-filter: add new atom "signature" atom”
  1. ref-filter: add new atom "signature" atomnsengaw4c via GitGitGadget, Dec 27, 2022
  2. Junio C HamanoDec 27, 2022
  3. NSENGIYUMVA WILBERFORCEJan 2, 2023
  4. Christian CouderJan 2, 2023
  5. Junio C HamanoJan 3, 2023
  6. Jeff KingDec 27, 2022
  7. NSENGIYUMVA WILBERFORCEJan 2, 2023
  8. 0/1 ref-filter: add new "signature" atomNsengiyumva Wilberforce, Jan 10, 2023
  9. 1/1 ref-filter: add new "signature" atomNsengiyumva Wilberforce, Jan 10, 2023
  10. 0/1 ref-filter: add new "signature" atomNsengiyumva Wilberforce, Jan 16, 2023
  11. 1/1 ref-filter: add new "signature" atomNsengiyumva Wilberforce, Jan 16, 2023
  12. 0/1 ref-filter: add new "signature" atomNsengiyumva Wilberforce, Mar 11, 2023
  13. 1/1 ref-filter: add new "signature" atomNsengiyumva Wilberforce, Mar 11, 2023
  14. Junio C HamanoMar 14, 2023
  15. Kousik SanagavarapuApr 28, 2023
  16. Kousik SanagavarapuApr 29, 2023
  17. Junio C HamanoJan 26, 2023
  18. Christian CouderJan 10, 2023
  19. NSENGIYUMVA WILBERFORCEJan 8, 2023

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.