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

@ -119,7 +119,8 @@ static void read_packs_from_stdin(struct string_list *to)
}
static int cmd_multi_pack_index_write(int argc, const char **argv,
const char *prefix)
const char *prefix,
struct repository *repo UNUSED)
{
struct option *options;
static struct option builtin_multi_pack_index_write_options[] = {
@ -183,7 +184,8 @@ static int cmd_multi_pack_index_write(int argc, const char **argv,
}
static int cmd_multi_pack_index_verify(int argc, const char **argv,
const char *prefix)
const char *prefix,
struct repository *repo UNUSED)
{
struct option *options;
static struct option builtin_multi_pack_index_verify_options[] = {
@ -210,7 +212,8 @@ static int cmd_multi_pack_index_verify(int argc, const char **argv,
}
static int cmd_multi_pack_index_expire(int argc, const char **argv,
const char *prefix)
const char *prefix,
struct repository *repo UNUSED)
{
struct option *options;
static struct option builtin_multi_pack_index_expire_options[] = {
@ -237,7 +240,8 @@ static int cmd_multi_pack_index_expire(int argc, const char **argv,
}
static int cmd_multi_pack_index_repack(int argc, const char **argv,
const char *prefix)
const char *prefix,
struct repository *repo UNUSED)
{
struct option *options;
static struct option builtin_multi_pack_index_repack_options[] = {
@ -271,7 +275,7 @@ static int cmd_multi_pack_index_repack(int argc, const char **argv,
int cmd_multi_pack_index(int argc,
const char **argv,
const char *prefix,
struct repository *repo UNUSED)
struct repository *repo)
{
int res;
parse_opt_subcommand_fn *fn = NULL;
@ -297,7 +301,7 @@ int cmd_multi_pack_index(int argc,
builtin_multi_pack_index_usage, 0);
FREE_AND_NULL(options);
res = fn(argc, argv, prefix);
res = fn(argc, argv, prefix, repo);
free(opts.object_dir);
return res;