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

[QUESTION] ref-filter: how to support atom like %an

From
ZheNing Hu <adlternative@gmail.com>
Date
May 15, 2021, 14:52 UTC
Message-ID
<CAOLTT8QBOgcz+Q_ODnbGq5r5CzrSdX+=DMT0pJS6iPTcP0VRjA@mail.gmail.com>
My current thinking is this:

First add a new member `short_name` in `struct valid_atom`, Then we can share a valid_atom item for the long name of an atom such as `%(authoremail)` and the short name of the atom `%ae` (%aE is not considered at the time). Something like:

[ATOM_AUTHOREMAIL] = { "ae", "authoremail", SOURCE_OBJ, FIELD_STR, person_email_atom_parser },

Then we need to do some work on atoms parsing: In the original design of `parse_ref_filter_atom()`, it relied on searching for `%(` and `)` to find an atom. Now we have to change the way of finding atoms: Currently I just replace `find_next()` to find a single `%`. If there is `(` after `%`, we can keep the original long name atoms parsing method, otherwise we are dealing with the short name atom, we need to pass the interval between the current `%` and the next single `%` to `parse_ref_filter_atom()`. Then we are in `parse_ref_filter_atom()`, we need to consider these situations:

1. %(authoremail:trim)
2. %(authoremail)
3. %ae
4. %ae:trim
5. %aeabc:trim
6. %ae:trimabcd...

As we can see, the situation is starting to get complicated. The more critical point is as in case 6: We cannot determine the end of a short name atom because it does not have an explicit `)` end. In this way, many of the `*_atom_parser` functions in `ref-filter.c` will not work, because most of them use `strcmp()` to check the attribute of an atom. If we want to support the short name `%ae`, that would require a large-scale rewrite.

Any good ideas, friends?

-- ZheNing Hu

Next: Junio C Hamano
Message 1 of 3 in “[QUESTION] ref-filter: how to support atom like %an”
  1. ZheNing HuMay 15, 2021
  2. Junio C HamanoMay 16, 2021
  3. ZheNing HuMay 17, 2021

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.