Re: Regression in `git diff --quiet HEAD` when a new file is staged
- From
Lidong Yan <yldhome2d2@gmail.com>
- Date
- Oct 22, 2025, 04:46 UTC
- Message-ID
- <E76C71D8-103E-4C37-B05C-86DC180BD519@gmail.com>
- In-Reply-To
- <xmqqy0p4wcac.fsf@gitster.g>
Junio C Hamano <gitster@pobox.com> writes:
Show 21 quoted lines
>
> /* 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.
Thanks Lidong