Skip to content

Commit 918d4e1

Browse files
committed
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>
1 parent c5c31d3 commit 918d4e1

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

grep.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@ static struct grep_opt grep_defaults;
1616
void init_grep_defaults(void)
1717
{
1818
struct grep_opt *opt = &grep_defaults;
19+
static int run_once;
20+
21+
if (run_once)
22+
return;
23+
run_once++;
1924

2025
memset(opt, 0, sizeof(*opt));
2126
opt->relative = 1;

revision.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1048,9 +1048,9 @@ void init_revisions(struct rev_info *revs, const char *prefix)
10481048

10491049
revs->commit_format = CMIT_FMT_DEFAULT;
10501050

1051+
init_grep_defaults();
1052+
grep_init(&revs->grep_filter, prefix);
10511053
revs->grep_filter.status_only = 1;
1052-
revs->grep_filter.pattern_tail = &(revs->grep_filter.pattern_list);
1053-
revs->grep_filter.header_tail = &(revs->grep_filter.header_list);
10541054
revs->grep_filter.regflags = REG_NEWLINE;
10551055

10561056
diff_setup(&revs->diffopt);
@@ -1893,6 +1893,8 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, struct s
18931893
revs->diffopt.abbrev = revs->abbrev;
18941894
diff_setup_done(&revs->diffopt);
18951895

1896+
grep_commit_pattern_type(GREP_PATTERN_TYPE_UNSPECIFIED,
1897+
&revs->grep_filter);
18961898
compile_grep_patterns(&revs->grep_filter);
18971899

18981900
if (revs->reverse && revs->reflog_info)

0 commit comments

Comments
 (0)