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

[bug] git check-ignore returns the wrong exit code with -v when only a negative pattern matches

From
DGDavid 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.

Next: Jeff King
Message 1 of 4 in “[bug] git check-ignore returns the wrong exit code with -v when only a negative pattern matches”
  1. David GoldsteinSep 18, 2025
  2. Jeff KingSep 18, 2025
  3. Junio C HamanoSep 18, 2025
  4. David GoldsteinNov 29, 2025

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.