summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2012-10-09 16:40:03 -0700
committerJunio C Hamano <gitster@pobox.com>2012-10-09 23:21:29 -0700
commit918d4e1c907983d26b0c4d82d7f7abff4dbec4e5 (patch)
tree482617f59391d949c55002d1fe026870d02f1ba0
parentc5c31d3381d11903c01d51aff4437fe9f76d0268 (diff)
downloadgit-918d4e1c907983d26b0c4d82d7f7abff4dbec4e5.tar.gz
revisions: initialize revs->grep_filter using grep_init()
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>
-rw-r--r--grep.c5
-rw-r--r--revision.c6
2 files changed, 9 insertions, 2 deletions
diff --git a/grep.c b/grep.c
index 279a55933c..a947a68a7f 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 a09e60bedb..a4a931426f 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)