twaugh / patchutils

Manipulate patch files
GNU General Public License v2.0
139 stars 22 forks source link

grepdiff: invert match #36

Open camsteffen opened 4 years ago

camsteffen commented 4 years ago

There should be a flag like -v, --invert-match in grep.

See https://stackoverflow.com/questions/57628550/grepdiff-find-hunks-that-dont-match-a-given-regexp (someone else's question).

My use case is to "unstage hunks that do not match" in git:

git diff --staged -U1 | grepdiff foo --invert-match --output-matching=hunk | git apply --cached -R
twaugh commented 4 years ago

--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?

camsteffen commented 4 years ago

Thanks for your response. I'm also a little too busy to claim this right now.

jansmets commented 3 years ago

Would be useful indeed.