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:

committed by
Junio C Hamano

parent
6ea2d9d271
commit
6f33d8e255
@ -48,7 +48,8 @@ static char const * const builtin_sparse_checkout_list_usage[] = {
|
||||
NULL
|
||||
};
|
||||
|
||||
static int sparse_checkout_list(int argc, const char **argv, const char *prefix)
|
||||
static int sparse_checkout_list(int argc, const char **argv, const char *prefix,
|
||||
struct repository *repo UNUSED)
|
||||
{
|
||||
static struct option builtin_sparse_checkout_list_options[] = {
|
||||
OPT_END(),
|
||||
@ -443,7 +444,8 @@ static struct sparse_checkout_init_opts {
|
||||
int sparse_index;
|
||||
} init_opts;
|
||||
|
||||
static int sparse_checkout_init(int argc, const char **argv, const char *prefix)
|
||||
static int sparse_checkout_init(int argc, const char **argv, const char *prefix,
|
||||
struct repository *repo UNUSED)
|
||||
{
|
||||
struct pattern_list pl;
|
||||
char *sparse_filename;
|
||||
@ -770,7 +772,8 @@ static struct sparse_checkout_add_opts {
|
||||
int use_stdin;
|
||||
} add_opts;
|
||||
|
||||
static int sparse_checkout_add(int argc, const char **argv, const char *prefix)
|
||||
static int sparse_checkout_add(int argc, const char **argv, const char *prefix,
|
||||
struct repository *repo UNUSED)
|
||||
{
|
||||
static struct option builtin_sparse_checkout_add_options[] = {
|
||||
OPT_BOOL_F(0, "skip-checks", &add_opts.skip_checks,
|
||||
@ -808,7 +811,8 @@ static struct sparse_checkout_set_opts {
|
||||
int use_stdin;
|
||||
} set_opts;
|
||||
|
||||
static int sparse_checkout_set(int argc, const char **argv, const char *prefix)
|
||||
static int sparse_checkout_set(int argc, const char **argv, const char *prefix,
|
||||
struct repository *repo UNUSED)
|
||||
{
|
||||
int default_patterns_nr = 2;
|
||||
const char *default_patterns[] = {"/*", "!/*/", NULL};
|
||||
@ -866,7 +870,8 @@ static struct sparse_checkout_reapply_opts {
|
||||
} reapply_opts;
|
||||
|
||||
static int sparse_checkout_reapply(int argc, const char **argv,
|
||||
const char *prefix)
|
||||
const char *prefix,
|
||||
struct repository *repo UNUSED)
|
||||
{
|
||||
static struct option builtin_sparse_checkout_reapply_options[] = {
|
||||
OPT_BOOL(0, "cone", &reapply_opts.cone_mode,
|
||||
@ -901,7 +906,8 @@ static char const * const builtin_sparse_checkout_disable_usage[] = {
|
||||
};
|
||||
|
||||
static int sparse_checkout_disable(int argc, const char **argv,
|
||||
const char *prefix)
|
||||
const char *prefix,
|
||||
struct repository *repo UNUSED)
|
||||
{
|
||||
static struct option builtin_sparse_checkout_disable_options[] = {
|
||||
OPT_END(),
|
||||
@ -989,7 +995,8 @@ static int check_rules(struct pattern_list *pl, int null_terminated) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int sparse_checkout_check_rules(int argc, const char **argv, const char *prefix)
|
||||
static int sparse_checkout_check_rules(int argc, const char **argv, const char *prefix,
|
||||
struct repository *repo UNUSED)
|
||||
{
|
||||
static struct option builtin_sparse_checkout_check_rules_options[] = {
|
||||
OPT_BOOL('z', NULL, &check_rules_opts.null_termination,
|
||||
@ -1037,7 +1044,7 @@ static int sparse_checkout_check_rules(int argc, const char **argv, const char *
|
||||
int cmd_sparse_checkout(int argc,
|
||||
const char **argv,
|
||||
const char *prefix,
|
||||
struct repository *repo UNUSED)
|
||||
struct repository *repo)
|
||||
{
|
||||
parse_opt_subcommand_fn *fn = NULL;
|
||||
struct option builtin_sparse_checkout_options[] = {
|
||||
@ -1060,5 +1067,5 @@ int cmd_sparse_checkout(int argc,
|
||||
prepare_repo_settings(the_repository);
|
||||
the_repository->settings.command_requires_full_index = 0;
|
||||
|
||||
return fn(argc, argv, prefix);
|
||||
return fn(argc, argv, prefix, repo);
|
||||
}
|
||||
|
Reference in New Issue
Block a user