Re: feature request: git add--interactive --patch on regex-matched hunks only
- From
Nguyen Thai Ngoc Duy <pclouds@gmail.com>
- Date
- Jul 26, 2011, 12:44 UTC
- Message-ID
- <CACsJy8Birqg2Ldp1Mt4NWOq1aT0oigTcFA8S=RWcK5y+zstwDA@mail.gmail.com>
- In-Reply-To
- <20110726060903.GA29486@sigill.intra.peff.net>
On Tue, Jul 26, 2011 at 1:09 PM, Jeff King <peff@peff.net> wrote:
Show 11 quoted lines
> On Tue, Jul 26, 2011 at 12:57:46PM +0700, Nguyen Thai Ngoc Duy wrote: > >> It's my itch. I'm more than happy if you take care of the Perl part, >> I'll do the rest. While you're doing the Perl part, should we have >> both --match and --no-match? One filters in. The other filters out. I >> guess people may find filter-in case more helpful than the other. > > Yeah. Also, what about grep options like case-insensitivity? I don't > want to go too overboard with adding options that are unlikely to be > used. It is perl, so technically you can do "(?i:foo)" to match "foo" > case-insensitively.
Or even standard regex with [Ff][Oo][Oo]. We can wait until users complain about the lack of feature. I won't complain because I may need to match non-ascii letters (unless pcre does support unicode, then yes pleasssse)
> I don't think there's a way to do --no-match style negation in the > regex itself, though.
Your coding skills are needed :)
Show 11 quoted lines
>> I thought of this way initially, but I needed to split hunks in >> parse_diff and was stuck because I was not familiar with data >> structure used in git-add--interactive. > > Oh yeah, you mentioned splitting before. I'm not sure how that would > interact with this feature. In some cases, you'd want to split as much > as possible, and in other cases, you'd want a bigger hunk. So I actually > think it is an orthogonal feature to "autosplit" hunks before we show > them to the user. I.e., something like: > > git add -p --autosplit-hunks --hunk-match=...
Yep. Sometimes I do want --autosplit-hunks alone.
> (where maybe the names could be better, but hopefully you get the > point).
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>
-- Duy