git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Bart Trojanowski <bart@jukie.net>
To: git@vger.kernel.org
Subject: [PATCH] Add git-rev-list --invert-match
Date: Wed, 19 Sep 2007 16:26:15 -0400	[thread overview]
Message-ID: <20070919202615.GK3076@jukie.net> (raw)

Example usage:

  git log --invert-match --grep="uninteresting"

  This command will prune out all commits that match the grep pattern.

How it works:

  The --invert-match flag sets invert_match, in rev_info.  This boolean
  is later checked in commit_match() and if set it inverts the result of
  grep_buffer().
---
 revision.c |   11 ++++++++++-
 revision.h |    3 ++-
 2 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/revision.c b/revision.c
index 33d092c..57b2d0f 100644
--- a/revision.c
+++ b/revision.c
@@ -1182,6 +1182,10 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, const ch
 				regflags |= REG_ICASE;
 				continue;
 			}
+			if (!strcmp(arg, "--invert-match")) {
+				revs->invert_match = 1;
+				continue;
+			}
 			if (!strcmp(arg, "--all-match")) {
 				all_match = 1;
 				continue;
@@ -1383,11 +1387,16 @@ static int rewrite_parents(struct rev_info *revs, struct commit *commit)
 
 static int commit_match(struct commit *commit, struct rev_info *opt)
 {
+	int result;
+
 	if (!opt->grep_filter)
 		return 1;
-	return grep_buffer(opt->grep_filter,
+
+	result = grep_buffer(opt->grep_filter,
 			   NULL, /* we say nothing, not even filename */
 			   commit->buffer, strlen(commit->buffer));
+
+	return opt->invert_match ? !result : result;
 }
 
 static struct commit *get_revision_1(struct rev_info *revs)
diff --git a/revision.h b/revision.h
index 98a0a8f..ead04a7 100644
--- a/revision.h
+++ b/revision.h
@@ -48,7 +48,8 @@ struct rev_info {
 			parents:1,
 			reverse:1,
 			cherry_pick:1,
-			first_parent_only:1;
+			first_parent_only:1,
+			invert_match:1;
 
 	/* Diff flags */
 	unsigned int	diff:1,
-- 
1.5.3.1.154.g734e65

             reply	other threads:[~2007-09-19 20:26 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-09-19 20:26 Bart Trojanowski [this message]
2007-09-20  2:52 ` [PATCH] Add git-rev-list --invert-match 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       ` [PATCH] Add git-rev-list --invert-match Jeff King
2007-09-21  9:10         ` 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=20070919202615.GK3076@jukie.net \
    --to=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).