builtin: pass repository to sub commands

In 9b1cb5070f (builtin: add a repository parameter for builtin
functions, 2024-09-13) the repository was passed down to all builtin
commands. This allowed the repository to be passed down to lower layers
without depending on the global `the_repository` variable.

Continue this work by also passing down the repository parameter from
the command to sub-commands. This will help pass down the repository to
other subsystems and cleanup usage of global variables like
'the_repository' and 'the_hash_algo'.

Signed-off-by: Karthik Nayak <karthik.188@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Karthik Nayak
2024-11-25 15:55:30 +01:00
committed by Junio C Hamano
parent 6ea2d9d271
commit 6f33d8e255
17 changed files with 239 additions and 135 deletions

View File

@ -282,14 +282,16 @@ int cmd__parse_options_flags(int argc, const char **argv)
return parse_options_flags__cmd(argc, argv, test_flags);
}
static int subcmd_one(int argc, const char **argv, const char *prefix UNUSED)
static int subcmd_one(int argc, const char **argv, const char *prefix UNUSED,
struct repository *repo UNUSED)
{
printf("fn: subcmd_one\n");
print_args(argc, argv);
return 0;
}
static int subcmd_two(int argc, const char **argv, const char *prefix UNUSED)
static int subcmd_two(int argc, const char **argv, const char *prefix UNUSED,
struct repository *repo UNUSED)
{
printf("fn: subcmd_two\n");
print_args(argc, argv);
@ -319,7 +321,7 @@ static int parse_subcommand__cmd(int argc, const char **argv,
printf("opt: %d\n", opt);
return fn(argc, argv, NULL);
return fn(argc, argv, NULL, NULL);
}
int cmd__parse_subcommand(int argc, const char **argv)