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

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

From
Elijah Newren <newren@gmail.com>
Date
Feb 17, 2020, 21:07 UTC
Message-ID
<CABPp-BHaTK62W4_rUaJXNUPSfu9cBD5MrmjgbJeMuA+7s3+rGg@mail.gmail.com>
In-Reply-To
<xmqqeeutkkur.fsf@gitster-ct.c.googlers.com>
On Mon, Feb 17, 2020 at 12:41 PM Junio C Hamano <gitster@pobox.com> wrote:
Show 21 quoted lines
>
> Elijah Newren <newren@gmail.com> 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.

Previous: Junio C HamanoNext: Junio C Hamano
Message 5 of 9 in “check-ignore: fix handling with negated patterns”
  1. check-ignore: fix handling with negated patternsElijah Newren via GitGitGadget, Feb 17, 2020
  2. Junio C HamanoFeb 17, 2020
  3. Elijah NewrenFeb 17, 2020
  4. Junio C HamanoFeb 17, 2020
  5. Elijah NewrenFeb 17, 2020
  6. Junio C HamanoFeb 19, 2020
  7. check-ignore: fix documentation and implementation to matchElijah Newren via GitGitGadget, Feb 18, 2020
  8. Junio C HamanoFeb 18, 2020
  9. check-ignore: fix documentation and implementation to matchElijah Newren via GitGitGadget, Feb 18, 2020

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.