From: Jeff King <peff@peff.net>
To: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Cc: Bart Trojanowski <bart@jukie.net>, git@vger.kernel.org
Subject: Re: [PATCH] Add git-rev-list --invert-match
Date: Fri, 21 Sep 2007 00:18:21 -0400 [thread overview]
Message-ID: <20070921041821.GA28245@coredump.intra.peff.net> (raw)
In-Reply-To: <Pine.LNX.4.64.0709201403540.28395@racer.site>
On Thu, Sep 20, 2007 at 02:12:54PM +0100, Johannes Schindelin wrote:
> Further, it probably makes sense to have the option to say _both_: "Find
> me a commit that contains Bart in one line, but not Simpson, and that
> does not contain the word "Sverdoolaege" at all."
This is perhaps a little hack-ish compared to better grep support in the
core, but I find complex logic through command line options to be
somewhat unreadable. I prefer something more Perl-ish like this:
git-revgrep 'message =~ /bart/i
&& message !~ /Simpson/
&& author_name !~ /Sverdoolaege/'
or if you want to get complex:
git-revgrep '
return 0 if message =~ /Sverdoolaege/;
while(my $line = message =~ /^(.*bart.*)/gmi) {
return 1 if $line !~ /Simpson/;
}
return 0;'
where revgrep is the script below:
-- >8 --
#!/usr/bin/perl
use strict;
my $matcher = shift || '';
my $matcher_sub = eval "sub { $matcher }";
die $@ if $@;
my $input = do {
if(@ARGV == 1 && $ARGV[0] eq '-') {
\*STDIN;
}
else {
open(my $fh, '-|', qw(git log --pretty=raw), @ARGV)
or die "unable to open pipe to git log: $!";
$fh;
}
};
our $commit;
while(<$input>) {
if(/^commit /) {
try_match() if $commit;
$commit = $_;
}
else {
$commit .= $_;
}
}
try_match() if $commit;
exit 0;
sub try_match {
if($matcher_sub->()) {
print STDOUT $commit;
}
}
sub parse_person { $_[0] =~ /([^<]*) <([^>]*)> (.*)/ }
sub parse_author { return parse_person($commit =~ /^author (.*)/m) }
sub parse_committer { return parse_person($commit =~ /^committer (.*)/m) }
sub author_name { return (parse_author)[0] }
sub author_email { return (parse_author)[1] }
sub author_time { return (parse_author)[2] }
sub committer_name { return (parse_committer)[0] }
sub committer_email { return (parse_committer)[1] }
sub committer_time { return (parse_committer)[2] }
sub message { return ($commit =~ /^( +.*?^$)/ms)[0] }
next prev parent reply other threads:[~2007-09-21 4:18 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-09-19 20:26 [PATCH] Add git-rev-list --invert-match Bart Trojanowski
2007-09-20 2:52 ` Bart Trojanowski
2007-09-20 4:05 ` Junio C Hamano
2007-09-20 12:18 ` Bart Trojanowski
2007-09-20 10:32 ` Johannes Schindelin
2007-09-20 12:38 ` Bart Trojanowski
2007-09-20 13:12 ` Johannes Schindelin
2007-09-20 21:49 ` Junio C Hamano
2007-09-20 21:54 ` Johannes Schindelin
2007-09-22 1:38 ` [RFC] Add git-rev-list --not-(author|committer|grep)!=pattern Bart Trojanowski
2007-09-21 4:18 ` Jeff King [this message]
2007-09-21 9:10 ` [PATCH] Add git-rev-list --invert-match Johannes Schindelin
2007-09-21 9:19 ` 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
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20070921041821.GA28245@coredump.intra.peff.net \
--to=peff@peff.net \
--cc=Johannes.Schindelin@gmx.de \
--cc=bart@jukie.net \
--cc=git@vger.kernel.org \
/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.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
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 read-only IMAP folder(s) and NNTP newsgroup(s).