revision.c: reduce implicit dependency the_repository
[gitweb.git] / builtin / grep.c
index ee5a1bd355a5f239a23b524a3e05b9c8646f6bc8..0c3527242eb052810b4d6487954d241f16d4860d 100644 (file)
@@ -103,7 +103,8 @@ static void add_work(struct grep_opt *opt, const struct grep_source *gs)
 
        todo[todo_end].source = *gs;
        if (opt->binary != GREP_BINARY_TEXT)
-               grep_source_load_driver(&todo[todo_end].source);
+               grep_source_load_driver(&todo[todo_end].source,
+                                       opt->repo->index);
        todo[todo_end].done = 0;
        strbuf_reset(&todo[todo_end].out);
        todo_end = (todo_end + 1) % ARRAY_SIZE(todo);
@@ -497,7 +498,7 @@ static int grep_cache(struct grep_opt *opt, struct repository *repo,
                strbuf_addstr(&name, ce->name);
 
                if (S_ISREG(ce->ce_mode) &&
-                   match_pathspec(pathspec, name.buf, name.len, 0, NULL,
+                   match_pathspec(repo->index, pathspec, name.buf, name.len, 0, NULL,
                                   S_ISDIR(ce->ce_mode) ||
                                   S_ISGITLINK(ce->ce_mode))) {
                        /*
@@ -515,7 +516,7 @@ static int grep_cache(struct grep_opt *opt, struct repository *repo,
                                hit |= grep_file(opt, name.buf);
                        }
                } else if (recurse_submodules && S_ISGITLINK(ce->ce_mode) &&
-                          submodule_path_match(pathspec, name.buf, NULL)) {
+                          submodule_path_match(repo->index, pathspec, name.buf, NULL)) {
                        hit |= grep_submodule(opt, repo, pathspec, NULL, ce->name, ce->name);
                } else {
                        continue;
@@ -679,7 +680,7 @@ static int grep_directory(struct grep_opt *opt, const struct pathspec *pathspec,
 
        fill_directory(&dir, &the_index, pathspec);
        for (i = 0; i < dir.nr; i++) {
-               if (!dir_path_match(dir.entries[i], pathspec, 0, NULL))
+               if (!dir_path_match(&the_index, dir.entries[i], pathspec, 0, NULL))
                        continue;
                hit |= grep_file(opt, dir.entries[i]->name);
                if (hit && opt->status_only)
@@ -904,9 +905,9 @@ int cmd_grep(int argc, const char **argv, const char *prefix)
                OPT_END()
        };
 
-       init_grep_defaults();
+       init_grep_defaults(the_repository);
        git_config(grep_cmd_config, NULL);
-       grep_init(&opt, prefix);
+       grep_init(&opt, the_repository, prefix);
 
        /*
         * If there is no -- then the paths must exist in the working