Skip to content

diff: add -I/--ignore-matching-lines - #402

Open
ilainy wants to merge 4 commits into
uutils:mainfrom
ilainy:add-ignore-matching-lines
Open

ilainy wants to merge 4 commits into
uutils:mainfrom
ilainy:add-ignore-matching-lines

Conversation

@ilainy

@ilainy ilainy commented Nov 16, 2026

Copy link
Copy Markdown

GNU diff's -I / --ignore-matching-lines drops a hunk when all its inserted and deleted lines match the given BRE. This PR adds the four forms of the option, makes it repeatable, and implements hunk filtering for the normal output format.

Invalid BREs now exit with code 2 (e.g. '\': Trailing backslash), and when all hunks are dropped the exit status stays 1 because the files still differ.

I only covered the normal format for now. Unified/context output requires rewriting how hunks are built, so I left that for a follow-up.

The missing diff: prefix on usage errors is tracked in #394.

Closes #395.

@github-actions

github-actions Bot commented Nov 16, 2026 •

Copy link
Copy Markdown

GNU diffutils testsuite comparison:

Test results comparison:
  Current:   TOTAL: 33 / PASSED: 23 / FAILED: 6 / SKIPPED: 4
  Reference: TOTAL: 33 / PASSED: 22 / FAILED: 7 / SKIPPED: 4

Changes from main branch:
  TOTAL: +0
  PASSED: +1
  FAILED: -1

Test improvements (1):
  + ignore-matching-lines

@sylvestre

Copy link
Copy Markdown
Collaborator

it has been conflicting for more than 7 days, sorry! please rebase it

@ilainy
ilainy force-pushed the add-ignore-matching-lines branch from 30e0936 to 8e324cc Compare December 1, 2026 10:07
@ilainy

ilainy commented Dec 1, 2026

Copy link
Copy Markdown
Author

Rebased onto latest main, conflicts resolved, all tests pass.

Also noticed the -D from #422 doesn’t print anything for identical files (the fast path doesn’t exempt the ifdef format). Added a one-line fix, let me know if you’d rather have it as a separate commit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

diff - -I / --ignore-matching-lines is not implemented

2 participants