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

Re: [PATCH v5] diff: ensure consistent diff behavior with ignore options

From
Johannes Schindelin <johannes.schindelin@gmx.de>
Date
Oct 16, 2025, 14:55 UTC
Message-ID
<527ba5fb-5fc1-b34c-9c93-61cd919da78f@gmx.de>
In-Reply-To
<20250808033019.78817-1-yldhome2d2@gmail.com>
Hi,
On Fri, 8 Aug 2025, Lidong Yan wrote:
Show 18 quoted lines
> @@ -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

Previous: Lidong Yan
Message 35 of 35 in “git-diff: --ignore-matching-lines has no effect on the output when --name-only is used”
  1. hi@arnes.spaceJul 23, 2025
  2. Lidong YanJul 23, 2025
  3. Junio C HamanoJul 23, 2025
  4. Lidong YanJul 24, 2025
  5. Eric SunshineJul 24, 2025
  6. Lidong YanJul 24, 2025
  7. hi@arnes.spaceJul 25, 2025
  8. hi@arnes.spaceJul 25, 2025
  9. Lidong YanJul 25, 2025
  10. hi@arnes.spaceJul 25, 2025
  11. Jeff KingJul 25, 2025
  12. Junio C HamanoJul 25, 2025
  13. diff: ensure consistent diff behavior with -I<regex> across output formatsLidong Yan, Jul 29, 2025
  14. Junio C HamanoJul 30, 2025
  15. Jeff KingAug 2, 2025
  16. Lidong YanAug 3, 2025
  17. Junio C HamanoAug 3, 2025
  18. Junio C HamanoAug 4, 2025
  19. Jeff KingAug 4, 2025
  20. diff: ensure consistent diff behavior with -I<regex> across output formatsLidong Yan, Aug 3, 2025
  21. Junio C HamanoAug 4, 2025
  22. Lidong YanAug 4, 2025
  23. Junio C HamanoAug 4, 2025
  24. Lidong YanAug 5, 2025
  25. Junio C HamanoAug 5, 2025
  26. diff: ensure consistent diff behavior with ignore optionsLidong Yan, Aug 6, 2025
  27. Junio C HamanoAug 6, 2025
  28. Lidong YanAug 7, 2025
  29. Junio C HamanoAug 6, 2025
  30. Lidong YanAug 7, 2025
  31. diff: ensure consistent diff behavior with ignore optionsLidong Yan, Aug 7, 2025
  32. Junio C HamanoAug 7, 2025
  33. Lidong YanAug 8, 2025
  34. diff: ensure consistent diff behavior with ignore optionsLidong Yan, Aug 8, 2025
  35. Johannes SchindelinOct 16, 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.