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

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

From
Jeff King <peff@peff.net>
Date
Oct 21, 2025, 07:36 UTC
Message-ID
<20251021073640.GB259661@coredump.intra.peff.net>
In-Reply-To
<xmqqh5vww7xa.fsf@gitster.g>
On Sat, Oct 18, 2025 at 08:23:13AM -0700, Junio C Hamano wrote:
Show 13 quoted lines
> Jeff King <peff@peff.net> writes:
> 
> > I'm not sure which of these you mean:
> >
> >   - Do we still need to call diff_flush_patch_quietly() directly below
> >     the hunk above, in diff_flush()?
> >
> >   - Do we still need the dry-run code at all?
> 
> Both.  We do not have to call flush_quietly() and can call the real
> thing with output disabled.  The dry-run bit was only added to
> implement the flush_quietly() variant.  If we lose the only caller
> to flush_quietly(), all of the supporting infrastructure can go.

It's not the only caller, though. b55e6d36eb added another earlier in diff_flush(), to handle --name-status, etc (which was its original goal). That code possibly remains broken, even with my patch, and would wait either on Lidong's dry-run fixes, or lifting the /dev/null into the flush_quietly() function.

Show 20 quoted lines
> It concentrates only on the regression-fix aspect of the changes.
> Going forward, my preference is:
> 
>  * Apply your patch.  This is the base of the fix for 'maint' and
>    all branches.
> 
>  * As Lidong updates dry-run code by adding more "ah we are in
>    dry-run, so we should stop at the first change and se should be
>    silent" fixes, we can queue them on the 'master' front for the
>    preparation for a better future.  Note that the 'master' front
>    would contain your "In from_contents modes, run flush_quietly()
>    with output redirected to /dev/null".
> 
>  * Once we regain enough confidence for dry-run with the above
>    effort, we mark your "why not redirect to /dev/null for extra
>    protection?" code with NEEDSWORK comment to be removed after a
>    thorough code audit to ensure that dry-run is now sound.
> 
> And I do not mind if the NEEDSWORK comment stay there for extended
> period of time.
Yeah, that matched my thinking exactly.

But thinking on it more, I think the regression is slightly bigger than I originally counted. My view was that:

  - the attempt to fix "-I" was incomplete but did not make anything
    worse there
  - that attempt also broke "--quiet"

So we should first un-break "--quiet" as simply as possible, and then try to make the fix for "-I" more complete as a separate step. But I think "-I" may actually have regressed, too, since it is subject to printing the extra bogus output when trying to decide if the content-diff is applicable, which it did not do before.

So really, the regression fix should probably cover both of them (which it would if we move the /dev/null redirection into the flush_quietly() variant).

-Peff
Previous: Junio C HamanoNext: Junio C Hamano
Message 13 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.