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

Re: [RFC-PATCHv6 4/4] pathspec: allow querying for attributes

From
Stefan Beller <sbeller@google.com>
Date
May 17, 2016, 19:23 UTC
Message-ID
<CAGZ79kZ-xf167LiO+zY+B8BTYd-9h7u=dgpL=4tsEJDPgwq8CA@mail.gmail.com>
In-Reply-To
<xmqqvb2dxomo.fsf@gitster.mtv.corp.google.com>
On Mon, May 16, 2016 at 10:03 PM, Junio C Hamano <gitster@pobox.com> wrote:
Show 22 quoted lines
> When matching (i.e. the match_attrs() function), you would instead
> do
>
>         path = xmemdupz(name, namelen);
>         git_check_attr(path, item->attr_check);
>
> to grab values for only attributes that matter to you, instead of
> calling git_all_attrs() [*2*].
>
> After git_check_attr() returns, item->attr_check.check[0].attr would
> be git_attr("VAR1") and item->attr_check.check[0].value would be
> whatever setting the path has for the VAR1 attribute.  You can use
> your match_mode logic to compare it with the values .attr_match
> expects.
>
> You do not necessarily have to have the same number of elements in
> .attr_match and .attr_check.check by the way.  .attr_match might say
>
>         VAR1=VAL2 !VAR1 -VAR1
>
> which may be always false if these are ANDed together, but in order
> to evaluate it, you need only one git_attr_check_elem for VAR1.
So for the matching we would need to get the order right, i.e.
    const char *inspect_name = git_attr_name(item.attr_match[i].attr);
    for (j=0; j <  p.attr_check.check_nr; j++) {
        const char *cur_name = git_attr_name(p.attr_check.check[j].attr);
        if (!strcmp(inspect_name, cur_name))
            break;
    // now compare .attr_match[i] with attr_check.check[j]
This doesn't look cheap to me? Am I holding it wrong again?
Previous: Junio C HamanoNext: Junio C Hamano
Message 15 of 18 in “[RFC-PATCHv6 0/4] pathspec attrs [WAS pathspec labels [WAS submodule groups]]”
  1. Stefan BellerMay 17, 2016
  2. 1/4 Documentation: fix a typoStefan Beller, May 17, 2016
  3. 2/4 pathspec: move long magic parsing out of prefix_pathspecStefan Beller, May 17, 2016
  4. 3/4 pathspec: move prefix check out of the inner loopStefan Beller, May 17, 2016
  5. 4/4 pathspec: allow querying for attributesStefan Beller, May 17, 2016
  6. Junio C HamanoMay 17, 2016
  7. Stefan BellerMay 17, 2016
  8. Junio C HamanoMay 17, 2016
  9. Stefan BellerMay 17, 2016
  10. Junio C HamanoMay 17, 2016
  11. Stefan BellerMay 17, 2016
  12. Junio C HamanoMay 17, 2016
  13. Stefan BellerMay 17, 2016
  14. Junio C HamanoMay 17, 2016
  15. Stefan BellerMay 17, 2016
  16. Junio C HamanoMay 17, 2016
  17. Junio C HamanoMay 18, 2016
  18. Junio C HamanoMay 17, 2016

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.