[bug] git check-ignore returns the wrong exit code with -v when only a negative pattern matches
- From
- David Goldstein <dgoldstein0@gmail.com>
- Date
- Sep 18, 2025, 17:28 UTC
- Message-ID
- <CANavNqpHqVgHshUaToS51OGVuvx5FqxROP2PssHW9OELMLeBQQ@mail.gmail.com>
Hey folks, I think I found a git check-ignore bug. According to the docs, git check-ignore should only exit 0 if a file is ignored, but if an untracked file matches a negative pattern in .gitignore (or the file can be tracked if --no-index is also used), then git check-ignore -v <file> exits 0 when it should exit 1; without -v the exit code is correct (0).
https://github.com/dgoldstein0/git_bug_repro has a self-contained reproduction + repeated explanation.
This exists in all git versions I've tested, but I haven't tried to get the latest dev version to check if it's still a problem in the latest version.