From: Johannes Schindelin <Johannes.Schindelin@gmx.de>
To: Lidong Yan <yldhome2d2@gmail.com>
Cc: git@vger.kernel.org, gitster@pobox.com, hi@arnes.space,
michal@isc.org, peff@peff.net, 李博文 <charlieio@icloud.com>
Subject: Re: [PATCH v5] diff: ensure consistent diff behavior with ignore options
Date: Thu, 16 Oct 2025 16:55:07 +0200 (CEST) [thread overview]
Message-ID: <527ba5fb-5fc1-b34c-9c93-61cd919da78f@gmx.de> (raw)
In-Reply-To: <20250808033019.78817-1-yldhome2d2@gmail.com>
[-- Attachment #1: Type: text/plain, Size: 2120 bytes --]
Hi,
On Fri, 8 Aug 2025, Lidong Yan wrote:
> @@ -6778,8 +6816,15 @@ void diff_flush(struct diff_options *options)
> DIFF_FORMAT_CHECKDIFF)) {
> for (i = 0; i < q->nr; i++) {
> struct diff_filepair *p = q->queue[i];
> - if (check_pair_status(p))
> - flush_one_pair(p, options);
> +
> + if (!check_pair_status(p))
> + continue;
> +
> + if (options->flags.diff_from_contents &&
> + !diff_flush_patch_quietly(p, options))
> + continue;
> +
> + flush_one_pair(p, options);
> }
> separator++;
> }
I'll play Ἑρμῆς here and relay the bug report from
https://github.com/git/git/commit/77f8e1002be5c736e064ed0e656ba51c82d85b5d#r168025843:
fcharlie wrote:
This code will cause git diff --patch --raw to produce garbled output
under certain conditions (e.g., using --ignore-space-change and whitespace
changes). flush_one_pair will output --raw format, but because
diff_flush_patch_quietly has already output a patch, garbled output will
be produced (actually, no diff_flush_patch_quietly should be called here).
[...]
A few exchanges later, brandb97 (AKA Lidong Yan) suggested this patch:
diff --git a/diff.c b/diff.c
index 87fa16b730..4baf9b535e 100644
--- a/diff.c
+++ b/diff.c
@@ -1351,6 +1351,9 @@ static void emit_diff_symbol_from_struct(struct diff_options *o,
int len = eds->len;
unsigned flags = eds->flags;
+ if (o->dry_run)
+ return;
+
switch (s) {
case DIFF_SYMBOL_NO_LF_EOF:
context = diff_get_color_opt(o, DIFF_CONTEXT);
@@ -4420,7 +4423,7 @@ static void run_external_diff(const struct external_diff *pgm,
{
struct child_process cmd = CHILD_PROCESS_INIT;
struct diff_queue_struct *q = &diff_queued_diff;
- int quiet = !(o->output_format & DIFF_FORMAT_PATCH);
+ int quiet = !(o->output_format & DIFF_FORMAT_PATCH) || o->dry_run;
int rc;
/*
fcharlie then responded by promising to test that patch tomorrow.
I will hold off from releasing Git for Windows v2.51.1 to await the result
of this test.
Ciao,
Johannes
prev parent reply other threads:[~2025-10-16 14:55 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-23 5:47 git-diff: --ignore-matching-lines has no effect on the output when --name-only is used hi
2025-07-23 8:00 ` Lidong Yan
2025-07-23 17:09 ` Junio C Hamano
2025-07-24 1:56 ` Lidong Yan
2025-07-24 2:16 ` Eric Sunshine
2025-07-24 3:38 ` Lidong Yan
2025-07-25 6:00 ` hi
2025-07-25 6:06 ` hi
2025-07-25 6:46 ` Lidong Yan
2025-07-25 8:08 ` hi
2025-07-25 11:11 ` Jeff King
2025-07-25 15:20 ` Junio C Hamano
2025-07-29 8:18 ` [PATCH] diff: ensure consistent diff behavior with -I<regex> across output formats Lidong Yan
2025-07-30 0:28 ` Junio C Hamano
2025-08-02 10:22 ` Jeff King
2025-08-03 8:42 ` Lidong Yan
2025-08-03 15:43 ` Junio C Hamano
2025-08-04 4:39 ` Junio C Hamano
2025-08-04 12:42 ` Jeff King
2025-08-03 14:51 ` [PATCH v2] " Lidong Yan
2025-08-04 0:39 ` Junio C Hamano
2025-08-04 1:56 ` Lidong Yan
2025-08-04 4:36 ` Junio C Hamano
2025-08-05 9:23 ` Lidong Yan
2025-08-05 16:11 ` Junio C Hamano
2025-08-06 12:33 ` [PATCH v3] diff: ensure consistent diff behavior with ignore options Lidong Yan
2025-08-06 17:35 ` Junio C Hamano
2025-08-07 1:23 ` Lidong Yan
2025-08-06 20:56 ` Junio C Hamano
2025-08-07 1:39 ` Lidong Yan
2025-08-07 2:06 ` [PATCH v4] " Lidong Yan
2025-08-07 21:27 ` Junio C Hamano
2025-08-08 1:46 ` Lidong Yan
2025-08-08 3:30 ` [PATCH v5] " Lidong Yan
2025-10-16 14:55 ` Johannes Schindelin [this message]
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=527ba5fb-5fc1-b34c-9c93-61cd919da78f@gmx.de \
--to=johannes.schindelin@gmx.de \
--cc=charlieio@icloud.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=hi@arnes.space \
--cc=michal@isc.org \
--cc=peff@peff.net \
--cc=yldhome2d2@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
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;
as well as URLs for NNTP newsgroup(s).