mirror of
https://github.com/git-for-windows/git.git
synced 2026-04-30 06:58:55 -05:00
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
@@ -155,7 +155,8 @@ static int parse_mirror_opt(const struct option *opt, const char *arg, int not)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int add(int argc, const char **argv, const char *prefix)
|
||||
static int add(int argc, const char **argv, const char *prefix,
|
||||
struct repository *repo UNUSED)
|
||||
{
|
||||
int fetch = 0, fetch_tags = TAGS_DEFAULT;
|
||||
unsigned mirror = MIRROR_NONE;
|
||||
@@ -706,7 +707,8 @@ static void handle_push_default(const char* old_name, const char* new_name)
|
||||
}
|
||||
|
||||
|
||||
static int mv(int argc, const char **argv, const char *prefix)
|
||||
static int mv(int argc, const char **argv, const char *prefix,
|
||||
struct repository *repo UNUSED)
|
||||
{
|
||||
int show_progress = isatty(2);
|
||||
struct option options[] = {
|
||||
@@ -881,7 +883,8 @@ out:
|
||||
return result;
|
||||
}
|
||||
|
||||
static int rm(int argc, const char **argv, const char *prefix)
|
||||
static int rm(int argc, const char **argv, const char *prefix,
|
||||
struct repository *repo UNUSED)
|
||||
{
|
||||
struct option options[] = {
|
||||
OPT_END()
|
||||
@@ -1303,7 +1306,8 @@ static int show_all(void)
|
||||
return result;
|
||||
}
|
||||
|
||||
static int show(int argc, const char **argv, const char *prefix)
|
||||
static int show(int argc, const char **argv, const char *prefix,
|
||||
struct repository *repo UNUSED)
|
||||
{
|
||||
int no_query = 0, result = 0, query_flag = 0;
|
||||
struct option options[] = {
|
||||
@@ -1399,7 +1403,8 @@ static int show(int argc, const char **argv, const char *prefix)
|
||||
return result;
|
||||
}
|
||||
|
||||
static int set_head(int argc, const char **argv, const char *prefix)
|
||||
static int set_head(int argc, const char **argv, const char *prefix,
|
||||
struct repository *repo UNUSED)
|
||||
{
|
||||
int i, opt_a = 0, opt_d = 0, result = 0;
|
||||
struct strbuf buf = STRBUF_INIT, buf2 = STRBUF_INIT;
|
||||
@@ -1503,7 +1508,8 @@ static int prune_remote(const char *remote, int dry_run)
|
||||
return result;
|
||||
}
|
||||
|
||||
static int prune(int argc, const char **argv, const char *prefix)
|
||||
static int prune(int argc, const char **argv, const char *prefix,
|
||||
struct repository *repo UNUSED)
|
||||
{
|
||||
int dry_run = 0, result = 0;
|
||||
struct option options[] = {
|
||||
@@ -1534,7 +1540,8 @@ static int get_remote_default(const char *key, const char *value UNUSED,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int update(int argc, const char **argv, const char *prefix)
|
||||
static int update(int argc, const char **argv, const char *prefix,
|
||||
struct repository *repo UNUSED)
|
||||
{
|
||||
int i, prune = -1;
|
||||
struct option options[] = {
|
||||
@@ -1616,7 +1623,8 @@ static int set_remote_branches(const char *remotename, const char **branches,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int set_branches(int argc, const char **argv, const char *prefix)
|
||||
static int set_branches(int argc, const char **argv, const char *prefix,
|
||||
struct repository *repo UNUSED)
|
||||
{
|
||||
int add_mode = 0;
|
||||
struct option options[] = {
|
||||
@@ -1635,7 +1643,8 @@ static int set_branches(int argc, const char **argv, const char *prefix)
|
||||
return set_remote_branches(argv[0], argv + 1, add_mode);
|
||||
}
|
||||
|
||||
static int get_url(int argc, const char **argv, const char *prefix)
|
||||
static int get_url(int argc, const char **argv, const char *prefix,
|
||||
struct repository *repo UNUSED)
|
||||
{
|
||||
int i, push_mode = 0, all_mode = 0;
|
||||
const char *remotename = NULL;
|
||||
@@ -1674,7 +1683,8 @@ static int get_url(int argc, const char **argv, const char *prefix)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int set_url(int argc, const char **argv, const char *prefix)
|
||||
static int set_url(int argc, const char **argv, const char *prefix,
|
||||
struct repository *repo UNUSED)
|
||||
{
|
||||
int i, push_mode = 0, add_mode = 0, delete_mode = 0;
|
||||
int matches = 0, negative_matches = 0;
|
||||
@@ -1765,7 +1775,7 @@ out:
|
||||
int cmd_remote(int argc,
|
||||
const char **argv,
|
||||
const char *prefix,
|
||||
struct repository *repo UNUSED)
|
||||
struct repository *repo)
|
||||
{
|
||||
parse_opt_subcommand_fn *fn = NULL;
|
||||
struct option options[] = {
|
||||
@@ -1788,7 +1798,7 @@ int cmd_remote(int argc,
|
||||
PARSE_OPT_SUBCOMMAND_OPTIONAL);
|
||||
|
||||
if (fn) {
|
||||
return !!fn(argc, argv, prefix);
|
||||
return !!fn(argc, argv, prefix, repo);
|
||||
} else {
|
||||
if (argc) {
|
||||
error(_("unknown subcommand: `%s'"), argv[0]);
|
||||
|
||||
Reference in New Issue
Block a user