git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] Add git-rev-list --invert-match

From
Bart Trojanowski <bart@jukie.net>
Date
Sep 19, 2007, 20:26 UTC
Message-ID
<20070919202615.GK3076@jukie.net>
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
Next: Bart Trojanowski
Message 1 of 13 in “Add git-rev-list --invert-match”
  1. Add git-rev-list --invert-matchBart Trojanowski, Sep 19, 2007
  2. Add git-rev-list --invert-matchBart Trojanowski, Sep 20, 2007
  3. Junio C HamanoSep 20, 2007
  4. Bart TrojanowskiSep 20, 2007
  5. Johannes SchindelinSep 20, 2007
  6. Bart TrojanowskiSep 20, 2007
  7. Johannes SchindelinSep 20, 2007
  8. Junio C HamanoSep 20, 2007
  9. Johannes SchindelinSep 20, 2007
  10. [RFC] Add git-rev-list --not-(author|committer|grep)!=patternBart Trojanowski, Sep 22, 2007
  11. Jeff KingSep 21, 2007
  12. Johannes SchindelinSep 21, 2007
  13. Jeff KingSep 21, 2007

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.