git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: git@vger.kernel.org
Subject: [PATCH v2 4/7] revisions: initialize revs->grep_filter using grep_init()
Date: Wed, 10 Oct 2012 00:55:11 -0700	[thread overview]
Message-ID: <1349855714-17008-5-git-send-email-gitster@pobox.com> (raw)
In-Reply-To: <1349855714-17008-1-git-send-email-gitster@pobox.com>

Instead of using the hand-rolled initialization sequence,
use grep_init() to populate the necessary bits.  This opens
the door to allow the calling commands to optionally read
grep.* configuration variables via git_config() if they
want to.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 grep.c     | 5 +++++
 revision.c | 6 ++++--
 2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/grep.c b/grep.c
index 279a559..a947a68 100644
--- a/grep.c
+++ b/grep.c
@@ -16,6 +16,11 @@ static struct grep_opt grep_defaults;
 void init_grep_defaults(void)
 {
 	struct grep_opt *opt = &grep_defaults;
+	static int run_once;
+
+	if (run_once)
+		return;
+	run_once++;
 
 	memset(opt, 0, sizeof(*opt));
 	opt->relative = 1;
diff --git a/revision.c b/revision.c
index a09e60b..a4a9314 100644
--- a/revision.c
+++ b/revision.c
@@ -1048,9 +1048,9 @@ void init_revisions(struct rev_info *revs, const char *prefix)
 
 	revs->commit_format = CMIT_FMT_DEFAULT;
 
+	init_grep_defaults();
+	grep_init(&revs->grep_filter, prefix);
 	revs->grep_filter.status_only = 1;
-	revs->grep_filter.pattern_tail = &(revs->grep_filter.pattern_list);
-	revs->grep_filter.header_tail = &(revs->grep_filter.header_list);
 	revs->grep_filter.regflags = REG_NEWLINE;
 
 	diff_setup(&revs->diffopt);
@@ -1893,6 +1893,8 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, struct s
 	revs->diffopt.abbrev = revs->abbrev;
 	diff_setup_done(&revs->diffopt);
 
+	grep_commit_pattern_type(GREP_PATTERN_TYPE_UNSPECIFIED,
+				 &revs->grep_filter);
 	compile_grep_patterns(&revs->grep_filter);
 
 	if (revs->reverse && revs->reflog_info)
-- 
1.8.0.rc1.76.g5a375e6

  parent reply	other threads:[~2012-10-10  7:55 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-10-10  7:55 [PATCH v2 0/7] Tying loose ends on grep-pcre Junio C Hamano
2012-10-10  7:55 ` [PATCH v2 1/7] builtin/grep.c: make configuration callback more reusable Junio C Hamano
2012-10-10  7:55 ` [PATCH v2 2/7] grep: move the configuration parsing logic to grep.[ch] Junio C Hamano
2012-10-10  7:55 ` [PATCH v2 3/7] grep: move pattern-type bits support to top-level grep.[ch] Junio C Hamano
2012-10-10  7:55 ` Junio C Hamano [this message]
2012-10-10  7:55 ` [PATCH v2 5/7] log --grep: use the same helper to set -E/-F options as "git grep" Junio C Hamano
2012-10-10  7:55 ` [PATCH v2 6/7] log --grep: accept --basic-regexp and --perl-regexp Junio C Hamano
2012-10-10  7:55 ` [PATCH v2 7/7] log: honor grep.* configuration Junio C Hamano
2012-10-10 15:17 ` [PATCH v2 0/7] Tying loose ends on grep-pcre Michael Haggerty
2012-10-10 16:52   ` Junio C Hamano
2012-10-11  7:08     ` Michael Haggerty

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=1349855714-17008-5-git-send-email-gitster@pobox.com \
    --to=gitster@pobox.com \
    --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.
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 NNTP newsgroup(s).