From: Jeff King <peff@peff.net>
To: Nguyen Thai Ngoc Duy <pclouds@gmail.com>
Cc: Git Mailing List <git@vger.kernel.org>
Subject: Re: feature request: git add--interactive --patch on regex-matched hunks only
Date: Wed, 27 Jul 2011 02:03:04 -0600 [thread overview]
Message-ID: <20110727080303.GA8105@sigill.intra.peff.net> (raw)
In-Reply-To: <CACsJy8Birqg2Ldp1Mt4NWOq1aT0oigTcFA8S=RWcK5y+zstwDA@mail.gmail.com>
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
next prev parent reply other threads:[~2011-07-27 8:03 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-07-24 5:11 feature request: git add--interactive --patch on regex-matched hunks only Nguyen Thai Ngoc Duy
2011-07-25 21:55 ` Jeff King
2011-07-25 23:44 ` Junio C Hamano
2011-07-26 5:03 ` Jeff King
2011-07-26 3:03 ` Nguyen Thai Ngoc Duy
2011-07-26 5:14 ` Jeff King
2011-07-26 5:57 ` Nguyen Thai Ngoc Duy
2011-07-26 6:09 ` Jeff King
2011-07-26 12:44 ` Nguyen Thai Ngoc Duy
2011-07-26 13:03 ` Nguyen Thai Ngoc Duy
2011-07-27 8:10 ` Jeff King
2011-07-27 9:02 ` Nguyen Thai Ngoc Duy
2011-07-27 17:24 ` Jeff King
2011-07-27 8:03 ` Jeff King [this message]
2011-07-27 8:05 ` [PATCH 1/5] add--interactive: refactor patch mode argument processing Jeff King
2011-07-27 8:05 ` [PATCH 2/5] add--interactive: factor out regex error handling Jeff King
2011-07-27 8:05 ` [PATCH 3/5] add--interactive: allow hunk filtering on command line Jeff King
2011-07-27 8:05 ` [PATCH 4/5] add--interactive: allow negatation of hunk filters Jeff King
2011-07-27 8:06 ` [PATCH 5/5] add--interactive: add option to autosplit hunks Jeff King
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20110727080303.GA8105@sigill.intra.peff.net \
--to=peff@peff.net \
--cc=git@vger.kernel.org \
--cc=pclouds@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).