Skip to content

Commit 9b1cb50

Browse files
john-caigitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 4590f2e commit 9b1cb50

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

127 files changed

+703
-296
lines changed

builtin.h

Lines changed: 139 additions & 138 deletions
Large diffs are not rendered by default.

builtin/add.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,10 @@ int interactive_add(const char **argv, const char *prefix, int patch)
167167
return ret;
168168
}
169169

170-
static int edit_patch(int argc, const char **argv, const char *prefix)
170+
static int edit_patch(int argc,
171+
const char **argv,
172+
const char *prefix,
173+
struct repository *repo UNUSED)
171174
{
172175
char *file = git_pathdup("ADD_EDIT.patch");
173176
struct child_process child = CHILD_PROCESS_INIT;
@@ -358,7 +361,10 @@ static int add_files(struct dir_struct *dir, int flags)
358361
return exit_status;
359362
}
360363

361-
int cmd_add(int argc, const char **argv, const char *prefix)
364+
int cmd_add(int argc,
365+
const char **argv,
366+
const char *prefix,
367+
struct repository *repo UNUSED)
362368
{
363369
int exit_status = 0;
364370
struct pathspec pathspec;
@@ -387,7 +393,7 @@ int cmd_add(int argc, const char **argv, const char *prefix)
387393
if (edit_interactive) {
388394
if (pathspec_from_file)
389395
die(_("options '%s' and '%s' cannot be used together"), "--pathspec-from-file", "--edit");
390-
return(edit_patch(argc, argv, prefix));
396+
return(edit_patch(argc, argv, prefix, the_repository));
391397
}
392398
argc--;
393399
argv++;

builtin/am.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2298,7 +2298,10 @@ static int parse_opt_show_current_patch(const struct option *opt, const char *ar
22982298
return 0;
22992299
}
23002300

2301-
int cmd_am(int argc, const char **argv, const char *prefix)
2301+
int cmd_am(int argc,
2302+
const char **argv,
2303+
const char *prefix,
2304+
struct repository *repo UNUSED)
23022305
{
23032306
struct am_state state;
23042307
int binary = -1;

builtin/annotate.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@
77
#include "builtin.h"
88
#include "strvec.h"
99

10-
int cmd_annotate(int argc, const char **argv, const char *prefix)
10+
int cmd_annotate(int argc,
11+
const char **argv,
12+
const char *prefix,
13+
struct repository *repo UNUSED)
1114
{
1215
struct strvec args = STRVEC_INIT;
1316
int i;
@@ -18,5 +21,5 @@ int cmd_annotate(int argc, const char **argv, const char *prefix)
1821
strvec_push(&args, argv[i]);
1922
}
2023

21-
return cmd_blame(args.nr, args.v, prefix);
24+
return cmd_blame(args.nr, args.v, prefix, the_repository);
2225
}

builtin/apply.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,10 @@ static const char * const apply_usage[] = {
99
NULL
1010
};
1111

12-
int cmd_apply(int argc, const char **argv, const char *prefix)
12+
int cmd_apply(int argc,
13+
const char **argv,
14+
const char *prefix,
15+
struct repository *repo UNUSED)
1316
{
1417
int force_apply = 0;
1518
int options = 0;

builtin/archive.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,10 @@ static int run_remote_archiver(int argc, const char **argv,
7676
PARSE_OPT_KEEP_UNKNOWN_OPT | \
7777
PARSE_OPT_NO_INTERNAL_HELP )
7878

79-
int cmd_archive(int argc, const char **argv, const char *prefix)
79+
int cmd_archive(int argc,
80+
const char **argv,
81+
const char *prefix,
82+
struct repository *repo UNUSED)
8083
{
8184
const char *exec = "git-upload-archive";
8285
char *output = NULL;

builtin/bisect.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1411,7 +1411,10 @@ static int cmd_bisect__run(int argc, const char **argv, const char *prefix UNUSE
14111411
return res;
14121412
}
14131413

1414-
int cmd_bisect(int argc, const char **argv, const char *prefix)
1414+
int cmd_bisect(int argc,
1415+
const char **argv,
1416+
const char *prefix,
1417+
struct repository *repo UNUSED)
14151418
{
14161419
int res = 0;
14171420
parse_opt_subcommand_fn *fn = NULL;

builtin/blame.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -864,7 +864,10 @@ static void build_ignorelist(struct blame_scoreboard *sb,
864864
}
865865
}
866866

867-
int cmd_blame(int argc, const char **argv, const char *prefix)
867+
int cmd_blame(int argc,
868+
const char **argv,
869+
const char *prefix,
870+
struct repository *repo UNUSED)
868871
{
869872
struct rev_info revs;
870873
char *path = NULL;

builtin/branch.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -704,7 +704,10 @@ static int edit_branch_description(const char *branch_name)
704704
return 0;
705705
}
706706

707-
int cmd_branch(int argc, const char **argv, const char *prefix)
707+
int cmd_branch(int argc,
708+
const char **argv,
709+
const char *prefix,
710+
struct repository *repo UNUSED)
708711
{
709712
/* possible actions */
710713
int delete = 0, rename = 0, copy = 0, list = 0,

builtin/bugreport.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,10 @@ static void get_header(struct strbuf *buf, const char *title)
9898
strbuf_addf(buf, "\n\n[%s]\n", title);
9999
}
100100

101-
int cmd_bugreport(int argc, const char **argv, const char *prefix)
101+
int cmd_bugreport(int argc,
102+
const char **argv,
103+
const char *prefix,
104+
struct repository *repo UNUSED)
102105
{
103106
struct strbuf buffer = STRBUF_INIT;
104107
struct strbuf report_path = STRBUF_INIT;

0 commit comments

Comments
 (0)