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

Discrepancy between git-check-ignore and git-status for negated pattern

From
GFGuido Flohr <guido.flohr@cantanea.com>
Date
Oct 26, 2017, 18:40 UTC
Message-ID
<60C66671-B124-4933-AC91-31D9A202D11D@cantanea.com>
This .gitignore file does not work as expected with git-check-ignore:
    *.o
    !a.o
It seems that “git check-ignore a.o” ignores that “a.o” was re-included.  This is what happens:
    $ git --version
    git version 2.15.0.rc2.48.g4e40fb302
    $ mkdir repo
    $ cd repo
    $ git init
    Initialized empty Git repository in /path/to/repo/.git/
    $ echo '*.o' >.gitignore
    $ echo '!a.o' >>.gitignore
    $ >a.o
    $ >b.o
    $ git check-ignore a.o b.o
    a.o
    b.o
    $ git status --short
    ?? a.o
According to git-check-ignore, “a.o” is ignored.  According to git-status, it is not.
Is that a bug or did I miss something because of my limited search capabilities?
Tested on a Mac with current master from git.  The 2.13.4 binary from Mac Ports exhibits the same behavior. 
Thanks!
Message 1 of 1 in “Discrepancy between git-check-ignore and git-status for negated pattern”
  1. Guido FlohrOct 26, 2017

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.