Re: feature request: git add--interactive --patch on regex-matched hunks only
- From
Jeff King <peff@peff.net>
- Date
- Jul 27, 2011, 17:24 UTC
- Message-ID
- <20110727172408.GB16031@sigill.intra.peff.net>
- In-Reply-To
- <CACsJy8ByDUByZiX43_+4_49uB+h0AMCk9J+35kZJSKgBn2KZbA@mail.gmail.com>
On Wed, Jul 27, 2011 at 04:02:48PM +0700, Nguyen Thai Ngoc Duy wrote:
Show 5 quoted lines
> 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