From 38bbc2ea39372ce1b7eb494b31948f4a8a903f88 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nguy=E1=BB=85n=20Th=C3=A1i=20Ng=E1=BB=8Dc=20Duy?= Date: Fri, 21 Sep 2018 17:57:23 +0200 Subject: grep.c: remove implicit dependency on the_index MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Nguyễn Thái Ngọc Duy Signed-off-by: Junio C Hamano --- grep.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'grep.c') diff --git a/grep.c b/grep.c index e146ff20bb..6c0eede3a1 100644 --- a/grep.c +++ b/grep.c @@ -42,7 +42,7 @@ static void color_set(char *dst, const char *color_bytes) * We could let the compiler do this, but without C99 initializers * the code gets unwieldy and unreadable, so... */ -void init_grep_defaults(void) +void init_grep_defaults(struct repository *repo) { struct grep_opt *opt = &grep_defaults; static int run_once; @@ -52,6 +52,7 @@ void init_grep_defaults(void) run_once++; memset(opt, 0, sizeof(*opt)); + opt->repo = repo; opt->relative = 1; opt->pathname = 1; opt->max_depth = -1; @@ -149,12 +150,13 @@ int grep_config(const char *var, const char *value, void *cb) * default values from the template we read the configuration * information in an earlier call to git_config(grep_config). */ -void grep_init(struct grep_opt *opt, const char *prefix) +void grep_init(struct grep_opt *opt, struct repository *repo, const char *prefix) { struct grep_opt *def = &grep_defaults; int i; memset(opt, 0, sizeof(*opt)); + opt->repo = repo; opt->prefix = prefix; opt->prefix_length = (prefix && *prefix) ? strlen(prefix) : 0; opt->pattern_tail = &opt->pattern_list; @@ -1708,7 +1710,8 @@ static int look_ahead(struct grep_opt *opt, return 0; } -static int fill_textconv_grep(struct userdiff_driver *driver, +static int fill_textconv_grep(struct repository *r, + struct userdiff_driver *driver, struct grep_source *gs) { struct diff_filespec *df; @@ -1741,7 +1744,7 @@ static int fill_textconv_grep(struct userdiff_driver *driver, * structure. */ grep_read_lock(); - size = fill_textconv(the_repository, driver, df, &buf); + size = fill_textconv(r, driver, df, &buf); grep_read_unlock(); free_filespec(df); @@ -1837,7 +1840,7 @@ static int grep_source_1(struct grep_opt *opt, struct grep_source *gs, int colle try_lookahead = should_lookahead(opt); - if (fill_textconv_grep(textconv, gs) < 0) + if (fill_textconv_grep(opt->repo, textconv, gs) < 0) return 0; bol = gs->buf; -- cgit v1.2.3