Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/grep.c
diff options
context:
space:
mode:
authorMartin Ågren <martin.agren@gmail.com>2020-11-21 21:31:07 +0300
committerJunio C Hamano <gitster@pobox.com>2020-11-22 01:50:29 +0300
commit1d3878799f8260968ea9f6a75a92c4daca1da133 (patch)
treeb39016c5b5c1baddfc98117bc402b2bbd11a258c /grep.c
parentfaefdd61ec7c7f6f3c8c9907891465ac9a2a1475 (diff)
grep: don't set up a "default" repo for grep
`init_grep_defaults()` fills a `static struct grep_opt grep_defaults`. This struct is then used by `grep_init()` as a blueprint for other such structs. Notably, `grep_init()` takes a `struct repo *` and assigns it into the target struct. As a result, it is unnecessary for us to take a `struct repo *` in `init_grep_defaults()` as well. We assign it into the default struct and never look at it again. And in light of how we return early if we have already set up the default struct, it's not just unnecessary, but is also a bit confusing: If we are called twice and with different repos, is it a bug or a feature that we ignore the second repo? Drop the repo parameter for `init_grep_defaults()`. Signed-off-by: Martin Ågren <martin.agren@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'grep.c')
-rw-r--r--grep.c3
1 files changed, 1 insertions, 2 deletions
diff --git a/grep.c b/grep.c
index 54af9f813e..b351449f7f 100644
--- a/grep.c
+++ b/grep.c
@@ -57,7 +57,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(struct repository *repo)
+void init_grep_defaults(void)
{
struct grep_opt *opt = &grep_defaults;
static int run_once;
@@ -67,7 +67,6 @@ void init_grep_defaults(struct repository *repo)
run_once++;
memset(opt, 0, sizeof(*opt));
- opt->repo = repo;
opt->relative = 1;
opt->pathname = 1;
opt->max_depth = -1;