diff options
| author | John Cai <johncai86@gmail.com> | 2024-09-13 21:16:14 +0000 |
|---|---|---|
| committer | Junio C Hamano <gitster@pobox.com> | 2024-09-13 14:27:08 -0700 |
| commit | 9b1cb5070ffb581798763eaee85cec10da969e90 (patch) | |
| tree | c33af160245f49cfa7d6e4e797c928a7a9f749ed /git.c | |
| parent | 4590f2e9412378c61eac95966709c78766d326ba (diff) | |
builtin: add a repository parameter for builtin functions
In order to reduce the usage of the global the_repository, add a
parameter to builtin functions that will get passed a repository
variable.
This commit uses UNUSED on most of the builtin functions, as subsequent
commits will modify the actual builtins to pass the repository parameter
down.
Signed-off-by: John Cai <johncai86@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'git.c')
| -rw-r--r-- | git.c | 12 |
1 files changed, 6 insertions, 6 deletions
@@ -31,7 +31,7 @@ struct cmd_struct { const char *cmd; - int (*fn)(int, const char **, const char *); + int (*fn)(int, const char **, const char *, struct repository *); unsigned int option; }; @@ -441,7 +441,7 @@ static int handle_alias(int *argcp, const char ***argv) return ret; } -static int run_builtin(struct cmd_struct *p, int argc, const char **argv) +static int run_builtin(struct cmd_struct *p, int argc, const char **argv, struct repository *repo) { int status, help; struct stat st; @@ -479,9 +479,9 @@ static int run_builtin(struct cmd_struct *p, int argc, const char **argv) trace_argv_printf(argv, "trace: built-in: git"); trace2_cmd_name(p->cmd); - validate_cache_entries(the_repository->index); - status = p->fn(argc, argv, prefix); - validate_cache_entries(the_repository->index); + validate_cache_entries(repo->index); + status = p->fn(argc, argv, prefix, (p->option & RUN_SETUP)? repo : NULL); + validate_cache_entries(repo->index); if (status) return status; @@ -736,7 +736,7 @@ static void handle_builtin(int argc, const char **argv) builtin = get_builtin(cmd); if (builtin) - exit(run_builtin(builtin, argc, argv)); + exit(run_builtin(builtin, argc, argv, the_repository)); strvec_clear(&args); } |
