Thread (4 messages) flat view 4 messages, 3 authors, 2016-06-15

Re: [PATCH] grep --no-index: allow use of "git grep" outside a git repository

From: David Aguilar <hidden>
Date: 2016-06-15 22:48:02
Subsystem: documentation, the rest · Maintainers: Jonathan Corbet, Linus Torvalds

Possibly related (same subject, not in this thread)

On Fri, Jan 15, 2010 at 08:15:49PM -0800, Junio C Hamano wrote:
Jeff King [off-list ref] writes:
quoted
quoted
    git grep --all-match -e Junio -e Dscho
That one is a little harder (though it is not something I do very often,
and I had to actually read the docs to find what --all-match does):

  grep Junio `grep -l Dscho *`

which of course has problems with exotic filenames.
Also it doesn't find lines that match Dscho in the result ;-)

Realistically, this most often is used when grepping in the log, e.g.

    git log --all-match --author=peff --grep=test

I actually wish "log" to somehow default to --all-match mode at least when
using the --author option.  "Change by Jeff, or about test by anybody" is
rarely what I would want to look for.
Kinda like this?

I originally had it set grep_filter.all_match in --author only,
but then I thought "why author and not commiter too", so changing
the default seemed like the natural thing to do.  Or it could be
a cat brained idea, I dunno ;)

-- -- -- 8< -- -- -- 8< -- -- --
From 2277a6e512c2f597c6240f06c9e7d5ff83e2fe3f Mon Sep 17 00:00:00 2001
From: David Aguilar <redacted>
Date: Fri, 15 Jan 2010 21:18:36 -0800
Subject: [PATCH] Make --all-match the default in "log" family

'git log --author=peff --grep=test' means "search for commits by Jeff,
or about test by anybody," which is rarely what what we want to do.
The original behavior can by achieved by specifying --no-all-match.

Reference: http://article.gmane.org/gmane.comp.version-control.git/137197
Signed-off-by: David Aguilar <redacted>
---
 Documentation/rev-list-options.txt |    1 +
 revision.c                         |    3 +++
 t/t7002-grep.sh                    |    2 +-
 3 files changed, 5 insertions(+), 1 deletions(-)
diff --git a/Documentation/rev-list-options.txt b/Documentation/rev-list-options.txt
index 1f57aed..0ce1008 100644
--- a/Documentation/rev-list-options.txt
+++ b/Documentation/rev-list-options.txt
@@ -179,6 +179,7 @@ endif::git-rev-list[]
 --all-match::
 	Limit the commits output to ones that match all given --grep,
 	--author and --committer instead of ones that match at least one.
+	--all-match is the defaullt and can be disabled with --no-all-match.
 
 -i::
 --regexp-ignore-case::
diff --git a/revision.c b/revision.c
index 25fa14d..64ebdc5 100644
--- a/revision.c
+++ b/revision.c
@@ -804,6 +804,7 @@ void init_revisions(struct rev_info *revs, const char *prefix)
 
 	revs->commit_format = CMIT_FMT_DEFAULT;
 
+	revs->grep_filter.all_match = 1;
 	revs->grep_filter.status_only = 1;
 	revs->grep_filter.pattern_tail = &(revs->grep_filter.pattern_list);
 	revs->grep_filter.regflags = REG_NEWLINE;
@@ -1222,6 +1223,8 @@ static int handle_revision_opt(struct rev_info *revs, int argc, const char **arg
 		revs->grep_filter.fixed = 1;
 	} else if (!strcmp(arg, "--all-match")) {
 		revs->grep_filter.all_match = 1;
+	} else if (!strcmp(arg, "--no-all-match")) {
+		revs->grep_filter.all_match = 0;
 	} else if (!prefixcmp(arg, "--encoding=")) {
 		arg += 11;
 		if (strcmp(arg, "none"))
diff --git a/t/t7002-grep.sh b/t/t7002-grep.sh
index 76c5e09..92ef534 100755
--- a/t/t7002-grep.sh
+++ b/t/t7002-grep.sh
@@ -358,7 +358,7 @@ test_expect_success 'log grep (4)' '
 
 test_expect_success 'log grep (5)' '
 	git log --author=Thor -F --grep=Thu --pretty=tformat:%s >actual &&
-	( echo third ; echo initial ) >expect &&
+	: >expect &&
 	test_cmp expect actual
 '
 
-- 
1.6.6.197.g2277
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help