Re: [PATCH] check-ignore: fix handling with negated patterns

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Feb 17, 2020 at 12:41 PM Junio C Hamano <gitster@xxxxxxxxx> wrote:
>
> Elijah Newren <newren@xxxxxxxxx> writes:
>
> >> I suspect that the above distorts history.  IIRC, it was meant as a
> >> tool to see which exact pattern in the exclude sequence had the
> >> final say for the given needle, written primarily as a debugging
> >> aid.  In that context, "This rule has the final say", whether the
> >> rule is a negative or positive, still means something.
> >
> > I can reword it; how does the following sound?
> >
> > check-ignore claims that it reports whether each path it is given is
> > excluded.  However, it fails to do so because it did not account for
> > negated patterns.
>
> I am not sure about "claims" part.
>
> Isn't it more like "check-ignore has been the tool that reports the
> rule that has final say on each of the paths it is given, but that
> is not very useful when the user wants to see if the path is
> excluded (e.g. the rule with the final say may be negative).

No, it is not more like that; the check-ignore manpage currently claims this:

       For each pathname given via the command-line or from a file via
--stdin, check whether the file is excluded by .gitignore (or
       other input files to the exclude mechanism) and output the path
if it is excluded.

Note also that this description at the beginning of the manpage says
nothing about reporting which rule has the final say.  And, in fact,
the command in default mode does not report which rule or rules were
involved.  All of that work falls to the --verbose flag, which was
documented as

           Also output details about the matching pattern (if any) for
each given pathname. For precedence rules within and between
           exclude sources, see gitignore(5).

Now, if you read both descriptions together, you find that these
claims are contradictory and that it cannot do both, so the "Also" bit
it leads with is a lie.  As such, my commit modified the definition of
verbose to make it instead read:

       Instead of printing the paths that are excluded, for each path
       that matches an exclude pattern print the exclude pattern
       together with the path.  (Matching an exclude pattern usually
       means the path is excluded, but if the pattern begins with '!'
       then it is a negated pattern and matching it means the path is
       NOT excluded.)

This was a change of description for the --verbose flag, not a change
of implementation.  Thus, in my opinion, no transition period is
needed: those who wanted to use check-ignore to see what rule would
have matched had to use --verbose before, and --verbose behaves the
same as before.

Those who wanted to use check-ignore without the --verbose flag to see
if a rule is excluded, get corrected behavior that will actually do
that.



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux