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;

builtin/bundle.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,10 @@ static int cmd_bundle_unbundle(int argc, const char **argv, const char *prefix)
226226
return ret;
227227
}
228228

229-
int cmd_bundle(int argc, const char **argv, const char *prefix)
229+
int cmd_bundle(int argc,
230+
const char **argv,
231+
const char *prefix,
232+
struct repository *repo UNUSED)
230233
{
231234
parse_opt_subcommand_fn *fn = NULL;
232235
struct option options[] = {

builtin/cat-file.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name,
191191
const char *ls_args[3] = { NULL };
192192
ls_args[0] = "ls-tree";
193193
ls_args[1] = obj_name;
194-
ret = cmd_ls_tree(2, ls_args, NULL);
194+
ret = cmd_ls_tree(2, ls_args, NULL, the_repository);
195195
goto cleanup;
196196
}
197197

@@ -923,7 +923,10 @@ static int batch_option_callback(const struct option *opt,
923923
return 0;
924924
}
925925

926-
int cmd_cat_file(int argc, const char **argv, const char *prefix)
926+
int cmd_cat_file(int argc,
927+
const char **argv,
928+
const char *prefix,
929+
struct repository *repo UNUSED)
927930
{
928931
int opt = 0;
929932
int opt_cw = 0;

builtin/check-attr.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,10 @@ static NORETURN void error_with_usage(const char *msg)
107107
usage_with_options(check_attr_usage, check_attr_options);
108108
}
109109

110-
int cmd_check_attr(int argc, const char **argv, const char *prefix)
110+
int cmd_check_attr(int argc,
111+
const char **argv,
112+
const char *prefix,
113+
struct repository *repo UNUSED)
111114
{
112115
struct attr_check *check;
113116
struct object_id initialized_oid;

builtin/check-ignore.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,10 @@ static int check_ignore_stdin_paths(struct dir_struct *dir, const char *prefix)
151151
return num_ignored;
152152
}
153153

154-
int cmd_check_ignore(int argc, const char **argv, const char *prefix)
154+
int cmd_check_ignore(int argc,
155+
const char **argv,
156+
const char *prefix,
157+
struct repository *repo UNUSED)
155158
{
156159
int num_ignored;
157160
struct dir_struct dir = DIR_INIT;

builtin/check-mailmap.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,10 @@ static void check_mailmap(struct string_list *mailmap, const char *contact)
4040
printf("<%.*s>\n", (int)maillen, mail);
4141
}
4242

43-
int cmd_check_mailmap(int argc, const char **argv, const char *prefix)
43+
int cmd_check_mailmap(int argc,
44+
const char **argv,
45+
const char *prefix,
46+
struct repository *repo UNUSED)
4447
{
4548
int i;
4649
struct string_list mailmap = STRING_LIST_INIT_NODUP;

builtin/check-ref-format.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,10 @@ static int check_ref_format_branch(const char *arg)
5151
return 0;
5252
}
5353

54-
int cmd_check_ref_format(int argc, const char **argv, const char *prefix)
54+
int cmd_check_ref_format(int argc,
55+
const char **argv,
56+
const char *prefix,
57+
struct repository *repo UNUSED)
5558
{
5659
int i;
5760
int normalize = 0;

builtin/checkout--worker.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,10 @@ static const char * const checkout_worker_usage[] = {
113113
NULL
114114
};
115115

116-
int cmd_checkout__worker(int argc, const char **argv, const char *prefix)
116+
int cmd_checkout__worker(int argc,
117+
const char **argv,
118+
const char *prefix,
119+
struct repository *repo UNUSED)
117120
{
118121
struct checkout state = CHECKOUT_INIT;
119122
struct option checkout_worker_options[] = {

builtin/checkout-index.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,10 @@ static int option_parse_stage(const struct option *opt,
208208
return 0;
209209
}
210210

211-
int cmd_checkout_index(int argc, const char **argv, const char *prefix)
211+
int cmd_checkout_index(int argc,
212+
const char **argv,
213+
const char *prefix,
214+
struct repository *repo UNUSED)
212215
{
213216
int i;
214217
struct lock_file lock_file = LOCK_INIT;

builtin/checkout.c

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1953,7 +1953,10 @@ static int checkout_main(int argc, const char **argv, const char *prefix,
19531953
return ret;
19541954
}
19551955

1956-
int cmd_checkout(int argc, const char **argv, const char *prefix)
1956+
int cmd_checkout(int argc,
1957+
const char **argv,
1958+
const char *prefix,
1959+
struct repository *repo UNUSED)
19571960
{
19581961
struct checkout_opts opts = CHECKOUT_OPTS_INIT;
19591962
struct option *options;
@@ -2000,7 +2003,10 @@ int cmd_checkout(int argc, const char **argv, const char *prefix)
20002003
checkout_usage);
20012004
}
20022005

2003-
int cmd_switch(int argc, const char **argv, const char *prefix)
2006+
int cmd_switch(int argc,
2007+
const char **argv,
2008+
const char *prefix,
2009+
struct repository *repo UNUSED)
20042010
{
20052011
struct checkout_opts opts = CHECKOUT_OPTS_INIT;
20062012
struct option *options = NULL;
@@ -2036,7 +2042,10 @@ int cmd_switch(int argc, const char **argv, const char *prefix)
20362042
switch_branch_usage);
20372043
}
20382044

2039-
int cmd_restore(int argc, const char **argv, const char *prefix)
2045+
int cmd_restore(int argc,
2046+
const char **argv,
2047+
const char *prefix,
2048+
struct repository *repo UNUSED)
20402049
{
20412050
struct checkout_opts opts = CHECKOUT_OPTS_INIT;
20422051
struct option *options;

builtin/clean.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -915,7 +915,10 @@ static void correct_untracked_entries(struct dir_struct *dir)
915915
dir->nr = dst;
916916
}
917917

918-
int cmd_clean(int argc, const char **argv, const char *prefix)
918+
int cmd_clean(int argc,
919+
const char **argv,
920+
const char *prefix,
921+
struct repository *repo UNUSED)
919922
{
920923
int i, res;
921924
int dry_run = 0, remove_directories = 0, quiet = 0, ignored = 0;

builtin/clone.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -956,7 +956,10 @@ static int path_exists(const char *path)
956956
return !stat(path, &sb);
957957
}
958958

959-
int cmd_clone(int argc, const char **argv, const char *prefix)
959+
int cmd_clone(int argc,
960+
const char **argv,
961+
const char *prefix,
962+
struct repository *repository UNUSED)
960963
{
961964
int is_bundle = 0, is_local;
962965
int reject_shallow = 0;

builtin/column.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,10 @@ static int column_config(const char *var, const char *value,
1818
return git_column_config(var, value, cb, &colopts);
1919
}
2020

21-
int cmd_column(int argc, const char **argv, const char *prefix)
21+
int cmd_column(int argc,
22+
const char **argv,
23+
const char *prefix,
24+
struct repository *repo UNUSED)
2225
{
2326
struct string_list list = STRING_LIST_INIT_DUP;
2427
struct strbuf sb = STRBUF_INIT;

builtin/commit-graph.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,10 @@ static int graph_write(int argc, const char **argv, const char *prefix)
331331
return result;
332332
}
333333

334-
int cmd_commit_graph(int argc, const char **argv, const char *prefix)
334+
int cmd_commit_graph(int argc,
335+
const char **argv,
336+
const char *prefix,
337+
struct repository *repo UNUSED)
335338
{
336339
parse_opt_subcommand_fn *fn = NULL;
337340
struct option builtin_commit_graph_options[] = {

builtin/commit-tree.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,10 @@ static int parse_file_arg_callback(const struct option *opt,
9090
return 0;
9191
}
9292

93-
int cmd_commit_tree(int argc, const char **argv, const char *prefix)
93+
int cmd_commit_tree(int argc,
94+
const char **argv,
95+
const char *prefix,
96+
struct repository *repo UNUSED)
9497
{
9598
static struct strbuf buffer = STRBUF_INIT;
9699
struct commit_list *parents = NULL;

builtin/commit.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1502,7 +1502,10 @@ static int git_status_config(const char *k, const char *v,
15021502
return git_diff_ui_config(k, v, ctx, NULL);
15031503
}
15041504

1505-
int cmd_status(int argc, const char **argv, const char *prefix)
1505+
int cmd_status(int argc,
1506+
const char **argv,
1507+
const char *prefix,
1508+
struct repository *repo UNUSED)
15061509
{
15071510
static int no_renames = -1;
15081511
static const char *rename_score_arg = (const char *)-1;
@@ -1641,7 +1644,10 @@ static int git_commit_config(const char *k, const char *v,
16411644
return git_status_config(k, v, ctx, s);
16421645
}
16431646

1644-
int cmd_commit(int argc, const char **argv, const char *prefix)
1647+
int cmd_commit(int argc,
1648+
const char **argv,
1649+
const char *prefix,
1650+
struct repository *repo UNUSED)
16451651
{
16461652
static struct wt_status s;
16471653
static struct option builtin_commit_options[] = {

builtin/config.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1392,7 +1392,10 @@ static int cmd_config_actions(int argc, const char **argv, const char *prefix)
13921392
return ret;
13931393
}
13941394

1395-
int cmd_config(int argc, const char **argv, const char *prefix)
1395+
int cmd_config(int argc,
1396+
const char **argv,
1397+
const char *prefix,
1398+
struct repository *repo UNUSED)
13961399
{
13971400
parse_opt_subcommand_fn *subcommand = NULL;
13981401
struct option subcommand_opts[] = {

builtin/count-objects.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,10 @@ static char const * const count_objects_usage[] = {
9595
NULL
9696
};
9797

98-
int cmd_count_objects(int argc, const char **argv, const char *prefix)
98+
int cmd_count_objects(int argc,
99+
const char **argv,
100+
const char *prefix,
101+
struct repository *repo UNUSED)
99102
{
100103
int human_readable = 0;
101104
struct option opts[] = {

0 commit comments

Comments
 (0)