On Mon, May 16, 2016 at 10:38 AM, Junio C Hamano <gitster@xxxxxxxxx> wrote: > Stefan Beller <sbeller@xxxxxxxxxx> 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. > >>>> + 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") > >> 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/) > > 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? > > 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 -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html