From: Sven Verdoolaege <skimo@kotnet.org>
To: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Cc: Junio C Hamano <gitster@pobox.com>, git@vger.kernel.org
Subject: Re: [PATCH] revision: allow selection of commits that do not match a pattern
Date: Sat, 07 Jul 2007 22:22:00 +0200 [thread overview]
Message-ID: <20070707202200.GF1528MdfPADPa@greensroom.kotnet.org> (raw)
In-Reply-To: <Pine.LNX.4.64.0707071957370.4093@racer.site>
On Sat, Jul 07, 2007 at 08:35:35PM +0100, Johannes Schindelin wrote:
> Why not keep it "add_grep", and do a
>
> struct grep_opt **filter = negated ?
> &revs->grep_neg_filter : &revs->grep_filter;
>
> Hm? You avoid an extra function that way.
[..]
>
> The parsing for "!" is again duplicated in add_message_grep(). Why not put
> it into add_grep(), and do
>
> negated = *pattern == '!';
> sprintf(pat, "%s^%s %s%s", negated ? "!" : "", field, prefix,
> pattern + negated);
>
> instead? No need to change the signature of add_grep(), and all callers
> get the '!' feature for free.
I can do these things, but they don't exactly improve readability, IMHO.
> > @@ -1249,6 +1277,10 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, const ch
> > compile_grep_patterns(revs->grep_filter);
> > }
> >
> > + if (revs->grep_neg_filter) {
> > + compile_grep_patterns(revs->grep_neg_filter);
> > + }
> > +
>
> Please lose the "{" and "}".
I may still need them for doing something with all_match...
> > @@ -1329,11 +1361,14 @@ static int rewrite_parents(struct rev_info *revs, struct commit *commit)
> >
> > static int commit_match(struct commit *commit, struct rev_info *opt)
> > {
> > - if (!opt->grep_filter)
> > - return 1;
> > - return grep_buffer(opt->grep_filter,
> > + return (!opt->grep_filter ||
> > + grep_buffer(opt->grep_filter,
> > + NULL, /* we say nothing, not even filename */
> > + commit->buffer, strlen(commit->buffer))) &&
> > + (!opt->grep_neg_filter ||
> > + !grep_buffer(opt->grep_neg_filter,
> > NULL, /* we say nothing, not even filename */
> > - commit->buffer, strlen(commit->buffer));
> > + commit->buffer, strlen(commit->buffer)));
> > }
>
> Urgh! That's not nice on my eyes.
You prefer
if (opt->grep_filter && !grep_buffer(opt->grep_filter,
NULL, /* we say nothing, not even filename */
commit->buffer, strlen(commit->buffer)))
return 0;
if (opt->grep_neg_filter && grep_buffer(opt->grep_neg_filter,
NULL, /* we say nothing, not even filename */
commit->buffer, strlen(commit->buffer)));
return 0;
return 1;
?
> Also, I suspect that the semantics are not yet clear, what should happen
> if all_match is unset.
So what are the semantics of all_match without negated matches?
It doesn't seem to be documented in git-rev-list.txt.
> BTW I suspect that a better way than having two filter lists is
> demonstrated in builtin-grep.c.
Could you be a bit more specific?
If you're talking about the GREP_NOT thing, then AFAICS that is line based
and I want these things to be commit based. That is I want to select
commits with either a or no lines that match a given pattern and not
commits that have a line that matches some patterns and not some others.
skimo
next prev parent reply other threads:[~2007-07-07 20:22 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-07-07 15:30 [PATCH] revision: allow selection of commits that do not match a pattern Sven Verdoolaege
2007-07-07 16:27 ` Johannes Schindelin
2007-07-07 16:52 ` Sven Verdoolaege
2007-07-07 17:33 ` Johannes Schindelin
2007-07-07 18:42 ` Sven Verdoolaege
2007-07-07 19:35 ` Johannes Schindelin
2007-07-07 20:22 ` Sven Verdoolaege [this message]
2007-07-08 10:57 ` [PATCH v3] " Sven Verdoolaege
2007-07-08 14:22 ` Johannes Schindelin
2007-07-08 14:57 ` Sven Verdoolaege
2007-07-11 17:42 ` 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=20070707202200.GF1528MdfPADPa@greensroom.kotnet.org \
--to=skimo@kotnet.org \
--cc=Johannes.Schindelin@gmx.de \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=skimo@liacs.nl \
/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).