From: David Aguilar <davvid@gmail.com>
To: Junio C Hamano <gitster@pobox.com>
Cc: Jeff King <peff@peff.net>,
git@vger.kernel.org, Nanako Shiraishi <nanako3@lavabit.com>
Subject: Re: [PATCH] grep --no-index: allow use of "git grep" outside a git repository
Date: Fri, 15 Jan 2010 22:51:36 -0800 [thread overview]
Message-ID: <20100116065135.GA15104@gmail.com> (raw)
In-Reply-To: <7vpr5ait1m.fsf@alter.siamese.dyndns.org>
On Fri, Jan 15, 2010 at 08:15:49PM -0800, Junio C Hamano wrote:
> Jeff King <peff@peff.net> writes:
>
> >> 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 <davvid@gmail.com>
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 <davvid@gmail.com>
---
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
next prev parent reply other threads:[~2010-01-16 6:51 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-01-13 16:13 Filenames and prefixes in extended diffs Andreas Gruenbacher
2010-01-13 19:49 ` Junio C Hamano
2010-01-14 0:16 ` Junio C Hamano
2010-01-15 13:32 ` Nanako Shiraishi
2010-01-15 18:09 ` Junio C Hamano
2010-01-15 20:50 ` [PATCH] grep: prepare to run outside of a work tree Junio C Hamano
2010-01-15 20:52 ` [PATCH] grep --no-index: allow use of "git grep" outside a git repository Junio C Hamano
2010-01-15 21:08 ` Jeff King
2010-01-16 1:05 ` Junio C Hamano
2010-01-16 1:15 ` Jeff King
2010-01-16 4:15 ` Junio C Hamano
2010-01-16 6:51 ` David Aguilar [this message]
2010-01-16 7:21 ` Junio C Hamano
2010-01-18 1:51 ` Jeff King
2010-01-18 3:35 ` Junio C Hamano
2010-01-18 4:02 ` Junio C Hamano
2010-01-18 5:57 ` Jeff King
2010-01-18 6:30 ` Junio C Hamano
2010-01-18 6:50 ` Jeff King
2010-01-18 23:22 ` Filenames and prefixes in extended diffs Andreas Gruenbacher
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20100116065135.GA15104@gmail.com \
--to=davvid@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=nanako3@lavabit.com \
--cc=peff@peff.net \
/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.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.