You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
--invert-match sounds like the right parameter name for this. Probably needs an invert_regexecs() similar to match regexecs(), and a way of switching between them appropriately (maybe a function pointer).
I don't have time to code this myself right now. Want to have a go at it?
Should --invert-match and --output-matching=hunk show individual hunks that don't match, or entire files that have at least one non-matching hunk?
How should --invert-match interact with --only-match=...? Should it invert the pattern matching or the line-type filtering? For example, with a hunk like this:
should grepdiff --invert-match --only-match=add foonot show this file because the addition lines match 'foo'?
I'm particularly interested in which workflows an --invert-match option enables. I'm thinking something like "using git, unstage hunks that do not match", but what others are there?
Should --invert-match and --output-matching=hunk show individual hunks that don't match, or entire files that have at least one non-matching hunk?
The former. It fits the use case. It's the corollary of grep --invert-match. The latter could be derived from it if needed but that seems like a pretty unlikely use case.
How should --invert-match interact with --only-match=...? Should it invert the pattern matching or the line-type filtering?
This seems like a question of order of operations. I think the sensible thing is to apply --only-match and then apply --invert-match. That way the --only-match is part of what gets inverted and so you get more functionality with the combined semantics. If you wanted to apply the --only-match filtering at the end, I think you could use a subsequent invocation of grepdiff.
For example, ...should grepdiff --invert-match --only-match=add foonot show this file because the addition lines match 'foo'?
Right, except I'd say "should not show this hunk".
I'm particularly interested in which workflows an --invert-match option enables. I'm thinking something like "using git, unstage hunks that do not match", but what others are there?
Yeah that is the use case I thought of. I can't think of a very different use case. A slightly different use case is to create a patch that partially reverts a commit.
Activity
twaugh commentedon Dec 6, 2019
--invert-matchsounds like the right parameter name for this. Probably needs aninvert_regexecs()similar to matchregexecs(), and a way of switching between them appropriately (maybe a function pointer).I don't have time to code this myself right now. Want to have a go at it?
camsteffen commentedon Dec 7, 2019
Thanks for your response. I'm also a little too busy to claim this right now.
jansmets commentedon Apr 11, 2021
Would be useful indeed.
twaugh commentedon Aug 27, 2025
Should
--invert-matchand--output-matching=hunkshow individual hunks that don't match, or entire files that have at least one non-matching hunk?How should
--invert-matchinteract with--only-match=...? Should it invert the pattern matching or the line-type filtering? For example, with a hunk like this:should
grepdiff --invert-match --only-match=add foonot show this file because the addition lines match 'foo'?I'm particularly interested in which workflows an
--invert-matchoption enables. I'm thinking something like "using git, unstage hunks that do not match", but what others are there?camsteffen commentedon Aug 29, 2025
The former. It fits the use case. It's the corollary of
grep --invert-match. The latter could be derived from it if needed but that seems like a pretty unlikely use case.This seems like a question of order of operations. I think the sensible thing is to apply
--only-matchand then apply--invert-match. That way the--only-matchis part of what gets inverted and so you get more functionality with the combined semantics. If you wanted to apply the--only-matchfiltering at the end, I think you could use a subsequent invocation of grepdiff.Right, except I'd say "should not show this hunk".
Yeah that is the use case I thought of. I can't think of a very different use case. A slightly different use case is to create a patch that partially reverts a commit.