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

Re: [PATCH 5/5] pathspec: record labels

From
Stefan Beller <sbeller@google.com>
Date
May 16, 2016, 17:46 UTC
Message-ID
<CAGZ79kbN_pzAVeAa-St_KRs60SbURTfKKP0v+do_+MK7orTkTg@mail.gmail.com>
In-Reply-To
<xmqqlh393nuv.fsf@gitster.mtv.corp.google.com>
On Mon, May 16, 2016 at 10:38 AM, Junio C Hamano <gitster@pobox.com> wrote:
Show 29 quoted lines
> Stefan Beller <sbeller@google.com> writes:
>
>>> Let's avoid "are meant to", which is merely to give you an excuse to
>>> say "it was meant to ... but the implementation did not quite achieve
>>> that goal".
>>>
>>>     The "label" attribute can be attached to paths, and the pathspec
>>>     mechanism is extended via the new ":(label=X)pattern/to/match"
>>
>> I wasn't sure about whether we want to have '=' or ':' as the separator
>> of "label" and its values. ...
>
> Oh, sorry, the above wasn't a suggestion to change : to = at all.  I
> was merely being sloppy in the details that is irrelevant to my main
> point (which is, it is better spend the bits you spent for "meant
> to" instead for saying clearly what it does).
>
>> ... But as that is only internal, we can be inconsistent to a new
>> public feature, so '=' seems better for the labeling system.
>
> I can buy that, too.  Good that my sloppy wording helped you think
> about it further ;-).
>
>> But still we do not enforce it early enough. Some crazy upstream may
>> add some labels which do not follow the requirements and then
>> tell downstream to run a command like `git foo "(label=!@#$)".
>> and then downstream curses at upstream as well as Git.
>
> That is why it is "warn and ignore", not "die".

So "warn and ignore" for data from .gitattributes and die for commandline arguments? That makes sense.

Show 20 quoted lines
>
>>>> +     if (ATTR_TRUE(check.value))
>>>> +             ret = 1; /* has all the labels */
>>>
>>> So this is "pretend that I have all the labels under the sun".
>>>
>>>> +     else if (ATTR_FALSE(check.value))
>>>> +             ret = 0; /* has no labels */
>>>
>>> I do not see a value in this.  What difference does it have compared
>>> to having a "label=" that explicitly says "I do not have one"?  What
>>> is your answer to an end-user question "When should I say 'label='
>>> and when should I say '!label'?"
>>>
>>> Just forbid it for now; we may find a better use for it later.
>>
>> I don't think we want to die in that code as it is in the data already.
>
> Is it?  I think this is coming from the command line pathspec magic,
> not from .gitattributes file recorded in the tree.
The 'check.value' is coming from the .gitattributes.

The 'required_labels' string list comes from the command line. ("The command line requires these labels")

Show 14 quoted lines
>
>> We need to allow the UNSET case, as otherwise you'd need to label
>> any path if using labels?
>
> You do need UNSET (roughly, "no label is mentioned for the path").
>
> If I want to say "Everything under Documentation/ and also things
> with label=doc", I'd say
>
>         git cmd "Documentation/" ":(label=doc)"
>
> and no path in Documentation/ need any label, i.e. for them, the
> labels are unset.  They will not be caught with ":(label=doc)"
> because they are not set, but that is OK.

right. that is what the end user should be able to do. That also means, we need to handle files with UNSET labels (all under Documentation/)

Show 5 quoted lines
>
> FALSE is different from UNSET.  It needs an explicit mention, i.e.
>
>         *.doc   doc
>         false.doc       -doc

and this is in the .gitattribues, so warn-and-ignore and by ignore we mean treat it as UNSET?

Show 14 quoted lines
>
> What's the difference between saying "-doc" and not saying anything?
> If you really want to explicitly say "doc attribute is unset for
> this path (perhaps because you may have other patterns that set the
> doc elsewhere), you would say "!doc", and you already have code for
> that.
>
>>         if (ATTR_TRUE(check.value))
>>                 ret = 1; /* has all the labels */
>>         else if (ATTR_FALSE(check.value))
>>                 die(_("Label attributes must not be unset"));
>
> The message is wrong.  You are dying because the user explicitly set
> it to false, not because the user made it unset.
Ok, so here is the warn-and-ignore code:
        if (ATTR_TRUE(check.value))
                ret = 1; /* has all the labels */
        else if (ATTR_FALSE(check.value)) {
                warning(_("Path '%s': Label must not be false. Treat
as if no label was set"), path);
                ret = 0;
        else if (ATTR_UNSET(check.value))
                ret = 0; /* has no labels */
        else {

Thanks, Stefan

Previous: Junio C HamanoNext: Junio C Hamano
Message 10 of 17 in “[PATCHv2 0/5] pathspec labels [WAS: submodule groups]”
  1. Stefan BellerMay 13, 2016
  2. 1/5 Documentation: fix a typoStefan Beller, May 13, 2016
  3. 2/5 Documentation: correct typo in example for querying attributesStefan Beller, May 13, 2016
  4. 3/5 pathspec: move long magic parsing out of prefix_pathspecStefan Beller, May 13, 2016
  5. 4/5 pathspec: move prefix check out of the inner loopStefan Beller, May 13, 2016
  6. 5/5 pathspec: record labelsStefan Beller, May 13, 2016
  7. Junio C HamanoMay 14, 2016
  8. Stefan BellerMay 16, 2016
  9. Junio C HamanoMay 16, 2016
  10. Stefan BellerMay 16, 2016
  11. Junio C HamanoMay 16, 2016
  12. Stefan BellerMay 16, 2016
  13. Junio C HamanoMay 16, 2016
  14. Stefan BellerMay 16, 2016
  15. Junio C HamanoMay 16, 2016
  16. Stefan BellerMay 16, 2016
  17. Junio C HamanoMay 16, 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.