On Tue, Jul 26, 2011 at 07:44:06PM +0700, Nguyen Thai Ngoc Duy wrote: > > I don't think there's a way to do --no-match style negation in the > > regex itself, though. > > Your coding skills are needed :) OK. Patches to follow. :) > Speaking of names, I'm usually bad at naming, but here goes. How about > --hunks=regex, --no-hunks=regex and --split-hunks? We may have > --[no-]case-hunks later on but that does sound bad. > > <over-engineering>maybe we should support multiple --hunks (or > --no-hunks, but not a mix of them), all must be matched, because there > are many lines in a hunk and people may want set patterns across > lines</over-engineering> My series lets you do multiple --hunks, and a hunk just needs to match any of them. Having "--no-hunks" implies that you can negate just some of the filters. Like: git add -p --hunks=foo --no-hunks=bar My series doesn't support that, though it would not be that big a deal to do so (the tricky part is defining the OR-ing and AND-ing sensibly). Something like: git add -p --negate-hunks --hunks=foo --hunks=bar makes it clear that you are either selecting or de-selecting with your filter. Technically somebody could also want: git add -p --hunk=foo --and --hunk=bar but I didn't want to get into parsing arbitrary boolean expressions. An easy flexible thing would be to just eval perl code like: git add -p --hunk-filter='/foo/ && !/bar/' but I don't think we want to tie ourselves to the implementation being in perl forever. Anyway, the series is: [1/5]: add--interactive: refactor patch mode argument processing [2/5]: add--interactive: factor out regex error handling [3/5]: add--interactive: allow hunk filtering on command line [4/5]: add--interactive: allow negatation of hunk filters [5/5]: add--interactive: add option to autosplit hunks Lightly tested by me. You can either build on top, or just squash them into your commits as appropriate. -Peff -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html