From: Jeff King Date: Wed, 27 Jul 2011 17:24:09 GMT Subject: Re: feature request: git add--interactive --patch on regex-matched hunks only Message-ID: <20110727172408.GB16031@sigill.intra.peff.net> In-Reply-To: On Wed, Jul 27, 2011 at 04:02:48PM +0700, Nguyen Thai Ngoc Duy wrote: > I was thinking of it as an extension of "git log -Sregex", where as -S > shows full diff of matched files, the new option only shows hunks that > actually match. Not sure if that is really useful though. On the other > hand, "git diff --hunk" is useful for me, I'll see if I can add that > option. I think it is more like "log -Gregex", which actually greps within the diff. It would not be too hard to adapt the "-G" code to return the set of hunks, rather than a simple "yes we have it". If you did that, it would make the perl bits way simpler: they would simply call "diff -Gregex" when creating the patch. I don't think "git diff --hunk" would be that hard, either. The trickiest part is that the diff code tries to output lines as soon as we get them. You'd have to buffer whole chunks. -Peff