summaryrefslogtreecommitdiff
path: root/revision.c
diff options
context:
space:
mode:
authorChristoph Junghans <ottxor@gentoo.org>2015-01-13 01:33:32 (GMT)
committerJunio C Hamano <gitster@pobox.com>2015-01-13 18:20:32 (GMT)
commit22dfa8a23de4bbb274027736edd3bd311dda2981 (patch)
tree98607b458d72d693ed6ee33005d785c05b7b7bc6 /revision.c
parent3c84ac86fc896c108b789b8eb26b169cc0e8088a (diff)
downloadgit-22dfa8a23de4bbb274027736edd3bd311dda2981.zip
git-22dfa8a23de4bbb274027736edd3bd311dda2981.tar.gz
git-22dfa8a23de4bbb274027736edd3bd311dda2981.tar.bz2
log: teach --invert-grep option
"git log --grep=<string>" shows only commits with messages that match the given string, but sometimes it is useful to be able to show only commits that do *not* have certain messages (e.g. "show me ones that are not FIXUP commits"). Originally, we had the invert-grep flag in grep_opt, but because "git grep --invert-grep" does not make sense except in conjunction with "--files-with-matches", which is already covered by "--files-without-matches", it was moved it to revisions structure. To have the flag there expresses the function to the feature better. When the newly inserted two tests run, the history would have commits with messages "initial", "second", "third", "fourth", "fifth", "sixth" and "Second", committed in this order. The commits that does not match either "th" or "Sec" is "second" and "initial". For the case insensitive case only "initial" matches. Signed-off-by: Christoph Junghans <ottxor@gentoo.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'revision.c')
-rw-r--r--revision.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/revision.c b/revision.c
index 615535c..84b33a3 100644
--- a/revision.c
+++ b/revision.c
@@ -1952,6 +1952,8 @@ static int handle_revision_opt(struct rev_info *revs, int argc, const char **arg
grep_set_pattern_type_option(GREP_PATTERN_TYPE_PCRE, &revs->grep_filter);
} else if (!strcmp(arg, "--all-match")) {
revs->grep_filter.all_match = 1;
+ } else if (!strcmp(arg, "--invert-grep")) {
+ revs->invert_grep = 1;
} else if ((argcount = parse_long_opt("encoding", argv, &optarg))) {
if (strcmp(optarg, "none"))
git_log_output_encoding = xstrdup(optarg);
@@ -2848,7 +2850,7 @@ static int commit_match(struct commit *commit, struct rev_info *opt)
(char *)message, strlen(message));
strbuf_release(&buf);
unuse_commit_buffer(commit, message);
- return retval;
+ return opt->invert_grep ? !retval : retval;
}
static inline int want_ancestry(const struct rev_info *revs)