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

BUG: git-check-ignore documentation doesn't come close to describing what it really does

From
Britton Kerin <britton.kerin@gmail.com>
Date
Jul 12, 2022, 23:02 UTC
Message-ID
<CAC4O8c9izkV5vbnE6MH8-RwnxRbUONxJxYZO+hb1J0ewuDtX+w@mail.gmail.com>
It begins:
       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.
In fact it just reports matches from .gitignore etc:
     $ cat .gitignore
     *.o
     !*.dont_ignore
     $ ls
     bar.o.dont_ignore  foo.o
     $ git check-ignore -v -n *
     .gitignore:2:!*.dont_ignore bar.o.dont_ignore
     .gitignore:1:*.o foo.o
     $ # Even more confusing without -v -n:
     $ git check-ignore *
     bar.o.dont_ignore
     foo.o
The EXIT STATUS section is even more wrong:
     EXIT STATUS
            0
                One or more of the provided paths is ignored.
            1
                None of the provided paths are ignored.
            128
                A fatal error was encountered.
but:
     $ if git check-ignore foo.o.dont_ignore; then echo exited true;
else echo exited false; fi
     foo.o.dont_ignore
     exited true
     $

IMO the behavior of git-check-ignore is the correct and useful behavior and the documentation should simply be fixed to reflect the fact that it just lists matching entries rather than wrongly claiming that it returns the overall result of the ignore calculation.

Britton
Next: Elijah Newren
Message 1 of 5 in “BUG: git-check-ignore documentation doesn't come close to describing what it really does”
  1. Britton KerinJul 12, 2022
  2. Elijah NewrenJul 13, 2022
  3. Junio C HamanoJul 13, 2022
  4. Britton Leo KerinJul 18, 2022
  5. Junio C HamanoJul 19, 2022

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.