`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>
----
static void init_walken_defaults(void)
{
- init_grep_defaults(the_repository);
+ init_grep_defaults();
}
...
OPT_END()
};
- init_grep_defaults(the_repository);
+ init_grep_defaults();
git_config(grep_cmd_config, NULL);
grep_init(&opt, the_repository, prefix);
static void init_log_defaults(void)
{
- init_grep_defaults(the_repository);
+ init_grep_defaults();
init_diff_ui_defaults();
decoration_style = auto_decoration_style();
* 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;
run_once++;
memset(opt, 0, sizeof(*opt));
- opt->repo = repo;
opt->relative = 1;
opt->pathname = 1;
opt->max_depth = -1;
void *output_priv;
};
-void init_grep_defaults(struct repository *);
+void init_grep_defaults(void);
int grep_config(const char *var, const char *value, void *);
void grep_init(struct grep_opt *, struct repository *repo, const char *prefix);
void grep_destroy(void);
revs->commit_format = CMIT_FMT_DEFAULT;
revs->expand_tabs_in_log_default = 8;
- init_grep_defaults(revs->repo);
+ init_grep_defaults();
grep_init(&revs->grep_filter, revs->repo, prefix);
revs->grep_filter.status_only = 1;