From: Jeff King <peff@peff•net>
To: Lidong Yan <yldhome2d2@gmail•com>
Cc: Junio C Hamano <gitster@pobox•com>,
Jake Zimmerman <jake@zimmerman•io>,
git@vger•kernel.org
Subject: Re: Regression in `git diff --quiet HEAD` when a new file is staged
Date: Wed, 22 Oct 2025 05:14:33 -0400 [thread overview]
Message-ID: <20251022091433.GC853931@coredump.intra.peff.net> (raw)
In-Reply-To: <E76C71D8-103E-4C37-B05C-86DC180BD519@gmail.com>
On Wed, Oct 22, 2025 at 12:46:55PM +0800, Lidong Yan wrote:
> Junio C Hamano <gitster@pobox•com> writes:
> >
> > /* return 1 if any change is found; otherwise, return 0 */
> > static int diff_flush_patch_quietly(struct diff_filepair *p, struct diff_options *o)
> > {
> > @@ -6179,6 +6181,15 @@ static int diff_flush_patch_quietly(struct diff_filepair *p, struct diff_options
> > int saved_found_changes = o->found_changes;
> > int ret;
> >
> > + /*
> > + * run diff_flush_patch for the exit status. setting
> > + * options->file to /dev/null should be safe, because we
> > + * aren't supposed to produce any output anyway.
> > + */
> > + diff_free_file(o);
> > + o->file = xfopen("/dev/null", "w");
> > + o->close_file = 1;
> > + o->color_moved = 0;
> > o->dry_run = 1;
> > o->found_changes = 0;
> > diff_flush_patch(p, o);
> >
>
> This would make everything going to "/dev/null" after the flush_quietly() call.
> I think we need to restore o->file.
We probably also need to restore o->color_moved, too.
In the long run (and this is the kind of cleanup I was hoping you'd work
on for 'master'), we probably could drop that line entirely and just
skip running the moved-line detection when dry_run is set. Assuming it
even runs at all. From a quick look at the code, it looks like we only
do color-moved handling via diff_flush_patch_all_file_pairs(), so it
wouldn't trigger at all for the cases that do individual calls to
diff_flush_patch_quietly()?
-Peff
next prev parent reply other threads:[~2025-10-22 9:14 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-17 0:09 Regression in `git diff --quiet HEAD` when a new file is staged Jake Zimmerman
2025-10-17 7:51 ` Jeff King
2025-10-17 8:36 ` [PATCH] diff: restore redirection to /dev/null for diff_from_contents Jeff King
2025-10-17 18:22 ` Junio C Hamano
2025-10-19 21:09 ` Johannes Schindelin
2025-10-21 7:52 ` Jeff King
2025-10-17 11:44 ` Regression in `git diff --quiet HEAD` when a new file is staged Johannes Schindelin
2025-10-17 17:45 ` Junio C Hamano
2025-10-18 1:04 ` Lidong Yan
2025-10-18 9:42 ` Jeff King
2025-10-18 9:40 ` Jeff King
2025-10-18 15:23 ` Junio C Hamano
2025-10-21 7:36 ` Jeff King
2025-10-21 14:38 ` Junio C Hamano
2025-10-22 4:46 ` Lidong Yan
2025-10-22 9:14 ` Jeff King [this message]
2025-10-22 14:20 ` Lidong Yan
2025-10-22 14:31 ` Junio C Hamano
2025-10-22 16:28 ` Junio C Hamano
2025-10-22 9:11 ` Jeff King
2025-10-22 16:48 ` Junio C Hamano
2025-10-23 12:01 ` Jeff King
2025-10-23 12:15 ` Jeff King
2025-10-23 13:35 ` Junio C Hamano
2025-10-22 17:39 ` Junio C Hamano
2025-10-23 0:33 ` Lidong Yan
2025-10-23 13:42 ` Junio C Hamano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20251022091433.GC853931@coredump.intra.peff.net \
--to=peff@peff$(echo .)net \
--cc=git@vger$(echo .)kernel.org \
--cc=gitster@pobox$(echo .)com \
--cc=jake@zimmerman$(echo .)io \
--cc=yldhome2d2@gmail$(echo .)com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox