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

Re: git-diff: --ignore-matching-lines has no effect on the output when --name-only is used

From
Lidong Yan <yldhome2d2@gmail.com>
Date
Jul 23, 2025, 08:00 UTC
Message-ID
<12095AC3-BC38-48DB-95B4-394F9F7DE054@gmail.com>
In-Reply-To
<87a54v8nmz.fsf@arnes.space>
hi@arnes.space writes:
Show 8 quoted lines
> 
> I discovered that diff output is not filtered when the `--name-only`
> flag is given, it always lists all affected files. Is this a known bug?
> I could not find anything in the documentation.
> 
> Perhaps related, `--ignore-matching-lines` is ignored by my external
> diff helper difftastic[1]. I'm not sure if this is an upstream issue, or
> if the way external diff helpers are implemented is related to this at all.

The `—ignore-matching-lines` options is introduced in 296d4a94e72 (Michał Kępień 2020-10-20 08:48:09 +0200 5803) Since the Git documentation doesn't specify how git diff --ignore-matching-lines=<regex> is supposed to behave when used with --name-only, I'm not sure whether this is a bug. However, I'm confident that this is not an issue with your diff tool. The reason is that git diff uses the built-in diffcore_std() to filter out diff file pairs that shouldn't be output. However, in the latest Git source code, diffcore_std() does not filter file pairs based on ignore_regex.

It appears that ignore_regex only takes effect when using the built-in diff (builtin_diff). I'm not entirely certain about this, but if that's the case, then regardless of whether your external diff tool supports --ignore-matching-lines or not, this option is likely to have no effect when using an external diff.

Show 8 quoted lines
> 
> The behavior can be observed in git 2.49.0 using `git diff --no-ext-diff
> --name-only --ignore-matching-lines`.
> 
> Best,
> Arne
> 
> [1]: https://difftastic.wilfred.me.uk/
Cool diff tool

Thanks, Lidong

Previous: hi@arnes.spaceNext: Junio C Hamano
Message 2 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.