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

Regression in `git diff --quiet HEAD` when a new file is staged

From
JZJake Zimmerman <jake@zimmerman.io>
Date
Oct 17, 2025, 00:09 UTC
Message-ID
<CACJRbWjwOQwJB13CwTfvhV3p+Hbn4KrNM9AtBanGtUS4V_1MbQ@mail.gmail.com>

In git v2.51.1, `git diff --quiet HEAD` will actually print something if the diff output includes a new, staged file.

## To reproduce
    ❯ mkdir foo
    ❯ cd foo
    ❯ git init .
    Initialized empty Git repository in /Users/jez/foo/.git/
    ❯ gc --allow-empty -m "Initial empty commit"
    [master (root-commit) 858966f] Initial empty commit
    ❯ touch foo.txt
    ❯ git add foo.txt
    ❯ git diff --quiet HEAD

On git v2.51.0, the output of the last command is empty. On git v2.51.1, the output of the last command is this:

    diff --git a/foo.txt b/foo.txt
    new file mode 100644
    index 0000000..e69de29
## Expected behavior

The stated docs for `--quiet`: "Disable all output of the program," so I expect there to be no output, like in older versions.

## Likely cause
I ran a git bisect and isolated this commit:

b55e6d36ebce69136559add8fffd1a65df231518 ( https://github.com/git/git/commit/e1d3d61a45bfdc5031d2066c0e4505ebd8145777 )

"diff: ensure consistent diff behavior with ignore options"
Next: Jeff King
Message 1 of 27 in “Regression in `git diff --quiet HEAD` when a new file is staged”
  1. Jake ZimmermanOct 17, 2025
  2. Jeff KingOct 17, 2025
  3. diff: restore redirection to /dev/null for diff_from_contentsJeff King, Oct 17, 2025
  4. Junio C HamanoOct 17, 2025
  5. Johannes SchindelinOct 19, 2025
  6. Jeff KingOct 21, 2025
  7. Johannes SchindelinOct 17, 2025
  8. Junio C HamanoOct 17, 2025
  9. Lidong YanOct 18, 2025
  10. Jeff KingOct 18, 2025
  11. Jeff KingOct 18, 2025
  12. Junio C HamanoOct 18, 2025
  13. Jeff KingOct 21, 2025
  14. Junio C HamanoOct 21, 2025
  15. Lidong YanOct 22, 2025
  16. Jeff KingOct 22, 2025
  17. Lidong YanOct 22, 2025
  18. Junio C HamanoOct 22, 2025
  19. Junio C HamanoOct 22, 2025
  20. Jeff KingOct 22, 2025
  21. Junio C HamanoOct 22, 2025
  22. Jeff KingOct 23, 2025
  23. Jeff KingOct 23, 2025
  24. Junio C HamanoOct 23, 2025
  25. Junio C HamanoOct 22, 2025
  26. Lidong YanOct 23, 2025
  27. Junio C HamanoOct 23, 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.