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>
Karthik Nayak committed
Nov 25, 2024 at 15:55 UTC
6f33d8e255cb2ff738cd28eab22751efb7c2d6ce
17 files changed
+239
-135
builtin/bisect.c
+21
-11
@@ -1312,7 +1312,8 @@ static int bisect_run(struct bisect_terms *terms, int argc, const char **argv)
1312
return res;
1313
}
1314
1315
-static int cmd_bisect__reset(int argc, const char **argv, const char *prefix UNUSED)
1315
+static int cmd_bisect__reset(int argc, const char **argv, const char *prefix UNUSED,
1316
+ struct repository *repo UNUSED)
1317
{
1318
if (argc > 1)
1319
return error(_("'%s' requires either no argument or a commit"),
@@ -1320,7 +1321,8 @@ static int cmd_bisect__reset(int argc, const char **argv, const char *prefix UNU
1321
return bisect_reset(argc ? argv[0] : NULL);
1322
}
1323
1323
-static int cmd_bisect__terms(int argc, const char **argv, const char *prefix UNUSED)
1324
+static int cmd_bisect__terms(int argc, const char **argv, const char *prefix UNUSED,
1325
+ struct repository *repo UNUSED)
1326
{
1327
int res;
1328
struct bisect_terms terms = { 0 };
@@ -1333,7 +1335,8 @@ static int cmd_bisect__terms(int argc, const char **argv, const char *prefix UNU
1335
return res;
1336
}
1337
1336
-static int cmd_bisect__start(int argc, const char **argv, const char *prefix UNUSED)
1338
+static int cmd_bisect__start(int argc, const char **argv, const char *prefix UNUSED,
1339
+ struct repository *repo UNUSED)
1340
{
1341
int res;
1342
struct bisect_terms terms = { 0 };
@@ -1344,7 +1347,8 @@ static int cmd_bisect__start(int argc, const char **argv, const char *prefix UNU
1347
return res;
1348
}
1349
1347
-static int cmd_bisect__next(int argc, const char **argv UNUSED, const char *prefix)
1350
+static int cmd_bisect__next(int argc, const char **argv UNUSED, const char *prefix,
1351
+ struct repository *repo UNUSED)
1352
{
1353
int res;
1354
struct bisect_terms terms = { 0 };
@@ -1358,12 +1362,15 @@ static int cmd_bisect__next(int argc, const char **argv UNUSED, const char *pref
1362
return res;
1363
}
1364
1361
-static int cmd_bisect__log(int argc UNUSED, const char **argv UNUSED, const char *prefix UNUSED)
1365
+static int cmd_bisect__log(int argc UNUSED, const char **argv UNUSED,
1366
+ const char *prefix UNUSED,
1367
+ struct repository *repo UNUSED)
1368
{
1369
return bisect_log();
1370
}
1371
1366
-static int cmd_bisect__replay(int argc, const char **argv, const char *prefix UNUSED)
1372
+static int cmd_bisect__replay(int argc, const char **argv, const char *prefix UNUSED,
1373
+ struct repository *repo UNUSED)
1374
{
1375
int res;
1376
struct bisect_terms terms = { 0 };
@@ -1376,7 +1383,8 @@ static int cmd_bisect__replay(int argc, const char **argv, const char *prefix UN
1383
return res;
1384
}
1385
1379
-static int cmd_bisect__skip(int argc, const char **argv, const char *prefix UNUSED)
1386
+static int cmd_bisect__skip(int argc, const char **argv, const char *prefix UNUSED,
1387
+ struct repository *repo UNUSED)
1388
{
1389
int res;
1390
struct bisect_terms terms = { 0 };
@@ -1388,7 +1396,8 @@ static int cmd_bisect__skip(int argc, const char **argv, const char *prefix UNUS
1396
return res;
1397
}
1398
1391
-static int cmd_bisect__visualize(int argc, const char **argv, const char *prefix UNUSED)
1399
+static int cmd_bisect__visualize(int argc, const char **argv, const char *prefix UNUSED,
1400
+ struct repository *repo UNUSED)
1401
{
1402
int res;
1403
struct bisect_terms terms = { 0 };
@@ -1399,7 +1408,8 @@ static int cmd_bisect__visualize(int argc, const char **argv, const char *prefix
1408
return res;
1409
}
1410
1402
-static int cmd_bisect__run(int argc, const char **argv, const char *prefix UNUSED)
1411
+static int cmd_bisect__run(int argc, const char **argv, const char *prefix UNUSED,
1412
+ struct repository *repo UNUSED)
1413
{
1414
int res;
1415
struct bisect_terms terms = { 0 };
@@ -1415,7 +1425,7 @@ static int cmd_bisect__run(int argc, const char **argv, const char *prefix UNUSE
1425
int cmd_bisect(int argc,
1426
const char **argv,
1427
const char *prefix,
1418
- struct repository *repo UNUSED)
1428
+ struct repository *repo)
1429
{
1430
int res = 0;
1431
parse_opt_subcommand_fn *fn = NULL;
@@ -1451,7 +1461,7 @@ int cmd_bisect(int argc,
1461
} else {
1462
argc--;
1463
argv++;
1454
- res = fn(argc, argv, prefix);
1464
+ res = fn(argc, argv, prefix, repo);
1465
}
1466
1467
return is_bisect_success(res) ? 0 : -res;
builtin/bundle.c
+10
-6
@@ -67,7 +67,8 @@ static int parse_options_cmd_bundle(int argc,
67
return argc;
68
}
69
70
-static int cmd_bundle_create(int argc, const char **argv, const char *prefix) {
70
+static int cmd_bundle_create(int argc, const char **argv, const char *prefix,
71
+ struct repository *repo UNUSED) {
72
struct strvec pack_opts = STRVEC_INIT;
73
int version = -1;
74
int ret;
@@ -123,7 +124,8 @@ static int open_bundle(const char *path, struct bundle_header *header,
124
return read_bundle_header(path, header);
125
}
126
126
-static int cmd_bundle_verify(int argc, const char **argv, const char *prefix) {
127
+static int cmd_bundle_verify(int argc, const char **argv, const char *prefix,
128
+ struct repository *repo UNUSED) {
129
struct bundle_header header = BUNDLE_HEADER_INIT;
130
int bundle_fd = -1;
131
int quiet = 0;
@@ -164,7 +166,8 @@ cleanup:
166
return ret;
167
}
168
167
-static int cmd_bundle_list_heads(int argc, const char **argv, const char *prefix) {
169
+static int cmd_bundle_list_heads(int argc, const char **argv, const char *prefix,
170
+ struct repository *repo UNUSED) {
171
struct bundle_header header = BUNDLE_HEADER_INIT;
172
int bundle_fd = -1;
173
int ret;
@@ -189,7 +192,8 @@ cleanup:
192
return ret;
193
}
194
192
-static int cmd_bundle_unbundle(int argc, const char **argv, const char *prefix) {
195
+static int cmd_bundle_unbundle(int argc, const char **argv, const char *prefix,
196
+ struct repository *repo UNUSED) {
197
struct bundle_header header = BUNDLE_HEADER_INIT;
198
int bundle_fd = -1;
199
int ret;
@@ -231,7 +235,7 @@ cleanup:
235
int cmd_bundle(int argc,
236
const char **argv,
237
const char *prefix,
234
- struct repository *repo UNUSED)
238
+ struct repository *repo)
239
{
240
parse_opt_subcommand_fn *fn = NULL;
241
struct option options[] = {
@@ -247,5 +251,5 @@ int cmd_bundle(int argc,
251
252
packet_trace_identity("bundle");
253
250
- return !!fn(argc, argv, prefix);
254
+ return !!fn(argc, argv, prefix, repo);
255
}
builtin/commit-graph.c
+6
-4
@@ -62,7 +62,8 @@ static struct option *add_common_options(struct option *to)
62
return parse_options_concat(common_opts, to);
63
}
64
65
-static int graph_verify(int argc, const char **argv, const char *prefix)
65
+static int graph_verify(int argc, const char **argv, const char *prefix,
66
+ struct repository *repo UNUSED)
67
{
68
struct commit_graph *graph = NULL;
69
struct object_directory *odb = NULL;
@@ -214,7 +215,8 @@ static int git_commit_graph_write_config(const char *var, const char *value,
215
return 0;
216
}
217
217
-static int graph_write(int argc, const char **argv, const char *prefix)
218
+static int graph_write(int argc, const char **argv, const char *prefix,
219
+ struct repository *repo UNUSED)
220
{
221
struct string_list pack_indexes = STRING_LIST_INIT_DUP;
222
struct strbuf buf = STRBUF_INIT;
@@ -333,7 +335,7 @@ cleanup:
335
int cmd_commit_graph(int argc,
336
const char **argv,
337
const char *prefix,
336
- struct repository *repo UNUSED)
338
+ struct repository *repo)
339
{
340
parse_opt_subcommand_fn *fn = NULL;
341
struct option builtin_commit_graph_options[] = {
@@ -352,5 +354,5 @@ int cmd_commit_graph(int argc,
354
builtin_commit_graph_usage, 0);
355
FREE_AND_NULL(options);
356
355
- return fn(argc, argv, prefix);
357
+ return fn(argc, argv, prefix, repo);
358
}
builtin/config.c
+16
-9
@@ -826,7 +826,8 @@ static void display_options_init(struct config_display_options *opts)
826
}
827
}
828
829
-static int cmd_config_list(int argc, const char **argv, const char *prefix)
829
+static int cmd_config_list(int argc, const char **argv, const char *prefix,
830
+ struct repository *repo UNUSED)
831
{
832
struct config_location_options location_opts = CONFIG_LOCATION_OPTIONS_INIT;
833
struct config_display_options display_opts = CONFIG_DISPLAY_OPTIONS_INIT;
@@ -861,7 +862,8 @@ static int cmd_config_list(int argc, const char **argv, const char *prefix)
862
return 0;
863
}
864
864
-static int cmd_config_get(int argc, const char **argv, const char *prefix)
865
+static int cmd_config_get(int argc, const char **argv, const char *prefix,
866
+ struct repository *repo UNUSED)
867
{
868
struct config_location_options location_opts = CONFIG_LOCATION_OPTIONS_INIT;
869
struct config_display_options display_opts = CONFIG_DISPLAY_OPTIONS_INIT;
@@ -915,7 +917,8 @@ static int cmd_config_get(int argc, const char **argv, const char *prefix)
917
return ret;
918
}
919
918
-static int cmd_config_set(int argc, const char **argv, const char *prefix)
920
+static int cmd_config_set(int argc, const char **argv, const char *prefix,
921
+ struct repository *repo UNUSED)
922
{
923
struct config_location_options location_opts = CONFIG_LOCATION_OPTIONS_INIT;
924
const char *value_pattern = NULL, *comment_arg = NULL;
@@ -973,7 +976,8 @@ static int cmd_config_set(int argc, const char **argv, const char *prefix)
976
return ret;
977
}
978
976
-static int cmd_config_unset(int argc, const char **argv, const char *prefix)
979
+static int cmd_config_unset(int argc, const char **argv, const char *prefix,
980
+ struct repository *repo UNUSED)
981
{
982
struct config_location_options location_opts = CONFIG_LOCATION_OPTIONS_INIT;
983
const char *value_pattern = NULL;
@@ -1010,7 +1014,8 @@ static int cmd_config_unset(int argc, const char **argv, const char *prefix)
1014
return ret;
1015
}
1016
1013
-static int cmd_config_rename_section(int argc, const char **argv, const char *prefix)
1017
+static int cmd_config_rename_section(int argc, const char **argv, const char *prefix,
1018
+ struct repository *repo UNUSED)
1019
{
1020
struct config_location_options location_opts = CONFIG_LOCATION_OPTIONS_INIT;
1021
struct option opts[] = {
@@ -1039,7 +1044,8 @@ out:
1044
return ret;
1045
}
1046
1042
-static int cmd_config_remove_section(int argc, const char **argv, const char *prefix)
1047
+static int cmd_config_remove_section(int argc, const char **argv, const char *prefix,
1048
+ struct repository *repo UNUSED)
1049
{
1050
struct config_location_options location_opts = CONFIG_LOCATION_OPTIONS_INIT;
1051
struct option opts[] = {
@@ -1099,7 +1105,8 @@ static int show_editor(struct config_location_options *opts)
1105
return 0;
1106
}
1107
1102
-static int cmd_config_edit(int argc, const char **argv, const char *prefix)
1108
+static int cmd_config_edit(int argc, const char **argv, const char *prefix,
1109
+ struct repository *repo UNUSED)
1110
{
1111
struct config_location_options location_opts = CONFIG_LOCATION_OPTIONS_INIT;
1112
struct option opts[] = {
@@ -1395,7 +1402,7 @@ out:
1402
int cmd_config(int argc,
1403
const char **argv,
1404
const char *prefix,
1398
- struct repository *repo UNUSED)
1405
+ struct repository *repo)
1406
{
1407
parse_opt_subcommand_fn *subcommand = NULL;
1408
struct option subcommand_opts[] = {
@@ -1422,7 +1429,7 @@ int cmd_config(int argc,
1429
if (subcommand) {
1430
argc = parse_options(argc, argv, prefix, subcommand_opts, builtin_config_usage,
1431
PARSE_OPT_SUBCOMMAND_OPTIONAL|PARSE_OPT_KEEP_UNKNOWN_OPT);
1425
- return subcommand(argc, argv, prefix);
1432
+ return subcommand(argc, argv, prefix, repo);
1433
}
1434
1435
return cmd_config_actions(argc, argv, prefix);
builtin/gc.c
+13
-8
@@ -1561,7 +1561,8 @@ static int task_option_parse(const struct option *opt UNUSED,
1561
return 0;
1562
}
1563
1564
-static int maintenance_run(int argc, const char **argv, const char *prefix)
1564
+static int maintenance_run(int argc, const char **argv, const char *prefix,
1565
+ struct repository *repo UNUSED)
1566
{
1567
int i;
1568
struct maintenance_run_opts opts = MAINTENANCE_RUN_OPTS_INIT;
@@ -1623,7 +1624,8 @@ static char const * const builtin_maintenance_register_usage[] = {
1624
NULL
1625
};
1626
1626
-static int maintenance_register(int argc, const char **argv, const char *prefix)
1627
+static int maintenance_register(int argc, const char **argv, const char *prefix,
1628
+ struct repository *repo UNUSED)
1629
{
1630
char *config_file = NULL;
1631
struct option options[] = {
@@ -1687,7 +1689,8 @@ static char const * const builtin_maintenance_unregister_usage[] = {
1689
NULL
1690
};
1691
1690
-static int maintenance_unregister(int argc, const char **argv, const char *prefix)
1692
+static int maintenance_unregister(int argc, const char **argv, const char *prefix,
1693
+ struct repository *repo UNUSED)
1694
{
1695
int force = 0;
1696
char *config_file = NULL;
@@ -2917,7 +2920,8 @@ static const char *const builtin_maintenance_start_usage[] = {
2920
NULL
2921
};
2922
2920
-static int maintenance_start(int argc, const char **argv, const char *prefix)
2923
+static int maintenance_start(int argc, const char **argv, const char *prefix,
2924
+ struct repository *repo)
2925
{
2926
struct maintenance_start_opts opts = { 0 };
2927
struct option options[] = {
@@ -2940,7 +2944,7 @@ static int maintenance_start(int argc, const char **argv, const char *prefix)
2944
if (update_background_schedule(&opts, 1))
2945
die(_("failed to set up maintenance schedule"));
2946
2943
- if (maintenance_register(ARRAY_SIZE(register_args)-1, register_args, NULL))
2947
+ if (maintenance_register(ARRAY_SIZE(register_args)-1, register_args, NULL, repo))
2948
warning(_("failed to add repo to global config"));
2949
return 0;
2950
}
@@ -2950,7 +2954,8 @@ static const char *const builtin_maintenance_stop_usage[] = {
2954
NULL
2955
};
2956
2953
-static int maintenance_stop(int argc, const char **argv, const char *prefix)
2957
+static int maintenance_stop(int argc, const char **argv, const char *prefix,
2958
+ struct repository *repo UNUSED)
2959
{
2960
struct option options[] = {
2961
OPT_END()
@@ -2970,7 +2975,7 @@ static const char * const builtin_maintenance_usage[] = {
2975
int cmd_maintenance(int argc,
2976
const char **argv,
2977
const char *prefix,
2973
- struct repository *repo UNUSED)
2978
+ struct repository *repo)
2979
{
2980
parse_opt_subcommand_fn *fn = NULL;
2981
struct option builtin_maintenance_options[] = {
@@ -2984,5 +2989,5 @@ int cmd_maintenance(int argc,
2989
2990
argc = parse_options(argc, argv, prefix, builtin_maintenance_options,
2991
builtin_maintenance_usage, 0);
2987
- return fn(argc, argv, prefix);
2992
+ return fn(argc, argv, prefix, repo);
2993
}
builtin/hook.c
+4
-3
@@ -19,7 +19,8 @@ static const char * const builtin_hook_run_usage[] = {
19
NULL
20
};
21
22
-static int run(int argc, const char **argv, const char *prefix)
22
+static int run(int argc, const char **argv, const char *prefix,
23
+ struct repository *repo UNUSED)
24
{
25
int i;
26
struct run_hooks_opt opt = RUN_HOOKS_OPT_INIT;
@@ -70,7 +71,7 @@ usage:
71
int cmd_hook(int argc,
72
const char **argv,
73
const char *prefix,
73
- struct repository *repo UNUSED)
74
+ struct repository *repo)
75
{
76
parse_opt_subcommand_fn *fn = NULL;
77
struct option builtin_hook_options[] = {
@@ -81,5 +82,5 @@ int cmd_hook(int argc,
82
argc = parse_options(argc, argv, NULL, builtin_hook_options,
83
builtin_hook_usage, 0);
84
84
- return fn(argc, argv, prefix);
85
+ return fn(argc, argv, prefix, repo);
86
}
builtin/multi-pack-index.c
+10
-6
@@ -119,7 +119,8 @@ static void read_packs_from_stdin(struct string_list *to)
119
}
120
121
static int cmd_multi_pack_index_write(int argc, const char **argv,
122
- const char *prefix)
122
+ const char *prefix,
123
+ struct repository *repo UNUSED)
124
{
125
struct option *options;
126
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,
184
}
185
186
static int cmd_multi_pack_index_verify(int argc, const char **argv,
186
- const char *prefix)
187
+ const char *prefix,
188
+ struct repository *repo UNUSED)
189
{
190
struct option *options;
191
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,
212
}
213
214
static int cmd_multi_pack_index_expire(int argc, const char **argv,
213
- const char *prefix)
215
+ const char *prefix,
216
+ struct repository *repo UNUSED)
217
{
218
struct option *options;
219
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,
240
}
241
242
static int cmd_multi_pack_index_repack(int argc, const char **argv,
240
- const char *prefix)
243
+ const char *prefix,
244
+ struct repository *repo UNUSED)
245
{
246
struct option *options;
247
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,
275
int cmd_multi_pack_index(int argc,
276
const char **argv,
277
const char *prefix,
274
- struct repository *repo UNUSED)
278
+ struct repository *repo)
279
{
280
int res;
281
parse_opt_subcommand_fn *fn = NULL;
@@ -297,7 +301,7 @@ int cmd_multi_pack_index(int argc,
301
builtin_multi_pack_index_usage, 0);
302
FREE_AND_NULL(options);
303
300
- res = fn(argc, argv, prefix);
304
+ res = fn(argc, argv, prefix, repo);
305
306
free(opts.object_dir);
307
return res;
builtin/notes.c
+23
-13
@@ -431,7 +431,8 @@ static struct notes_tree *init_notes_check(const char *subcommand,
431
return t;
432
}
433
434
-static int list(int argc, const char **argv, const char *prefix)
434
+static int list(int argc, const char **argv, const char *prefix,
435
+ struct repository *repo UNUSED)
436
{
437
struct notes_tree *t;
438
struct object_id object;
@@ -468,9 +469,11 @@ static int list(int argc, const char **argv, const char *prefix)
469
return retval;
470
}
471
471
-static int append_edit(int argc, const char **argv, const char *prefix);
472
+static int append_edit(int argc, const char **argv, const char *prefix,
473
+ struct repository *repo UNUSED);
474
473
-static int add(int argc, const char **argv, const char *prefix)
475
+static int add(int argc, const char **argv, const char *prefix,
476
+ struct repository *repo)
477
{
478
int force = 0, allow_empty = 0;
479
const char *object_ref;
@@ -543,7 +546,7 @@ static int add(int argc, const char **argv, const char *prefix)
546
* argv[0-1].
547
*/
548
argv[0] = "edit";
546
- return append_edit(argc, argv, prefix);
549
+ return append_edit(argc, argv, prefix, repo);
550
}
551
fprintf(stderr, _("Overwriting existing notes for object %s\n"),
552
oid_to_hex(&object));
@@ -569,7 +572,8 @@ static int add(int argc, const char **argv, const char *prefix)
572
return 0;
573
}
574
572
-static int copy(int argc, const char **argv, const char *prefix)
575
+static int copy(int argc, const char **argv, const char *prefix,
576
+ struct repository *repo UNUSED)
577
{
578
int retval = 0, force = 0, from_stdin = 0;
579
const struct object_id *from_note, *note;
@@ -646,7 +650,8 @@ out:
650
return retval;
651
}
652
649
-static int append_edit(int argc, const char **argv, const char *prefix)
653
+static int append_edit(int argc, const char **argv, const char *prefix,
654
+ struct repository *repo UNUSED)
655
{
656
int allow_empty = 0;
657
const char *object_ref;
@@ -749,7 +754,8 @@ static int append_edit(int argc, const char **argv, const char *prefix)
754
return 0;
755
}
756
752
-static int show(int argc, const char **argv, const char *prefix)
757
+static int show(int argc, const char **argv, const char *prefix,
758
+ struct repository *repo UNUSED)
759
{
760
const char *object_ref;
761
struct notes_tree *t;
@@ -875,7 +881,8 @@ static int git_config_get_notes_strategy(const char *key,
881
return 0;
882
}
883
878
-static int merge(int argc, const char **argv, const char *prefix)
884
+static int merge(int argc, const char **argv, const char *prefix,
885
+ struct repository *repo UNUSED)
886
{
887
struct strbuf remote_ref = STRBUF_INIT, msg = STRBUF_INIT;
888
struct object_id result_oid;
@@ -1016,7 +1023,8 @@ static int remove_one_note(struct notes_tree *t, const char *name, unsigned flag
1023
return (flag & IGNORE_MISSING) ? 0 : status;
1024
}
1025
1019
-static int remove_cmd(int argc, const char **argv, const char *prefix)
1026
+static int remove_cmd(int argc, const char **argv, const char *prefix,
1027
+ struct repository *repo UNUSED)
1028
{
1029
unsigned flag = 0;
1030
int from_stdin = 0;
@@ -1059,7 +1067,8 @@ static int remove_cmd(int argc, const char **argv, const char *prefix)
1067
return retval;
1068
}
1069
1062
-static int prune(int argc, const char **argv, const char *prefix)
1070
+static int prune(int argc, const char **argv, const char *prefix,
1071
+ struct repository *repo UNUSED)
1072
{
1073
struct notes_tree *t;
1074
int show_only = 0, verbose = 0;
@@ -1088,7 +1097,8 @@ static int prune(int argc, const char **argv, const char *prefix)
1097
return 0;
1098
}
1099
1091
-static int get_ref(int argc, const char **argv, const char *prefix)
1100
+static int get_ref(int argc, const char **argv, const char *prefix,
1101
+ struct repository *repo UNUSED)
1102
{
1103
struct option options[] = { OPT_END() };
1104
char *notes_ref;
@@ -1109,7 +1119,7 @@ static int get_ref(int argc, const char **argv, const char *prefix)
1119
int cmd_notes(int argc,
1120
const char **argv,
1121
const char *prefix,
1112
- struct repository *repo UNUSED)
1122
+ struct repository *repo)
1123
{
1124
const char *override_notes_ref = NULL;
1125
parse_opt_subcommand_fn *fn = NULL;
@@ -1148,5 +1158,5 @@ int cmd_notes(int argc,
1158
strbuf_release(&sb);
1159
}
1160
1151
- return !!fn(argc, argv, prefix);
1161
+ return !!fn(argc, argv, prefix, repo);
1162
}
builtin/reflog.c
+11
-6
@@ -234,7 +234,8 @@ static int expire_total_callback(const struct option *opt,
234
return 0;
235
}
236
237
-static int cmd_reflog_show(int argc, const char **argv, const char *prefix)
237
+static int cmd_reflog_show(int argc, const char **argv, const char *prefix,
238
+ struct repository *repo UNUSED)
239
{
240
struct option options[] = {
241
OPT_END()
@@ -253,7 +254,8 @@ static int show_reflog(const char *refname, void *cb_data UNUSED)
254
return 0;
255
}
256
256
-static int cmd_reflog_list(int argc, const char **argv, const char *prefix)
257
+static int cmd_reflog_list(int argc, const char **argv, const char *prefix,
258
+ struct repository *repo UNUSED)
259
{
260
struct option options[] = {
261
OPT_END()
@@ -270,7 +272,8 @@ static int cmd_reflog_list(int argc, const char **argv, const char *prefix)
272
return refs_for_each_reflog(ref_store, show_reflog, NULL);
273
}
274
273
-static int cmd_reflog_expire(int argc, const char **argv, const char *prefix)
275
+static int cmd_reflog_expire(int argc, const char **argv, const char *prefix,
276
+ struct repository *repo UNUSED)
277
{
278
struct cmd_reflog_expire_cb cmd = { 0 };
279
timestamp_t now = time(NULL);
@@ -394,7 +397,8 @@ static int cmd_reflog_expire(int argc, const char **argv, const char *prefix)
397
return status;
398
}
399
397
-static int cmd_reflog_delete(int argc, const char **argv, const char *prefix)
400
+static int cmd_reflog_delete(int argc, const char **argv, const char *prefix,
401
+ struct repository *repo UNUSED)
402
{
403
int i, status = 0;
404
unsigned int flags = 0;
@@ -424,7 +428,8 @@ static int cmd_reflog_delete(int argc, const char **argv, const char *prefix)
428
return status;
429
}
430
427
-static int cmd_reflog_exists(int argc, const char **argv, const char *prefix)
431
+static int cmd_reflog_exists(int argc, const char **argv, const char *prefix,
432
+ struct repository *repo UNUSED)
433
{
434
struct option options[] = {
435
OPT_END()
@@ -467,7 +472,7 @@ int cmd_reflog(int argc,
472
PARSE_OPT_KEEP_DASHDASH | PARSE_OPT_KEEP_ARGV0 |
473
PARSE_OPT_KEEP_UNKNOWN_OPT);
474
if (fn)
470
- return fn(argc - 1, argv + 1, prefix);
475
+ return fn(argc - 1, argv + 1, prefix, repository);
476
else
477
return cmd_log_reflog(argc, argv, prefix, repository);
478
}
builtin/refs.c
+6
-4
@@ -12,7 +12,8 @@
12
#define REFS_VERIFY_USAGE \
13
N_("git refs verify [--strict] [--verbose]")
14
15
-static int cmd_refs_migrate(int argc, const char **argv, const char *prefix)
15
+static int cmd_refs_migrate(int argc, const char **argv, const char *prefix,
16
+ struct repository *repo UNUSED)
17
{
18
const char * const migrate_usage[] = {
19
REFS_MIGRATE_USAGE,
@@ -63,7 +64,8 @@ out:
64
return err;
65
}
66
66
-static int cmd_refs_verify(int argc, const char **argv, const char *prefix)
67
+static int cmd_refs_verify(int argc, const char **argv, const char *prefix,
68
+ struct repository *repo UNUSED)
69
{
70
struct fsck_options fsck_refs_options = FSCK_REFS_OPTIONS_DEFAULT;
71
const char * const verify_usage[] = {
@@ -93,7 +95,7 @@ static int cmd_refs_verify(int argc, const char **argv, const char *prefix)
95
int cmd_refs(int argc,
96
const char **argv,
97
const char *prefix,
96
- struct repository *repo UNUSED)
98
+ struct repository *repo)
99
{
100
const char * const refs_usage[] = {
101
REFS_MIGRATE_USAGE,
@@ -108,5 +110,5 @@ int cmd_refs(int argc,
110
};
111
112
argc = parse_options(argc, argv, prefix, opts, refs_usage, 0);
111
- return fn(argc, argv, prefix);
113
+ return fn(argc, argv, prefix, repo);
114
}
builtin/remote.c
+22
-12
@@ -155,7 +155,8 @@ static int parse_mirror_opt(const struct option *opt, const char *arg, int not)
155
return 0;
156
}
157
158
-static int add(int argc, const char **argv, const char *prefix)
158
+static int add(int argc, const char **argv, const char *prefix,
159
+ struct repository *repo UNUSED)
160
{
161
int fetch = 0, fetch_tags = TAGS_DEFAULT;
162
unsigned mirror = MIRROR_NONE;
@@ -706,7 +707,8 @@ static void handle_push_default(const char* old_name, const char* new_name)
707
}
708
709
709
-static int mv(int argc, const char **argv, const char *prefix)
710
+static int mv(int argc, const char **argv, const char *prefix,
711
+ struct repository *repo UNUSED)
712
{
713
int show_progress = isatty(2);
714
struct option options[] = {
@@ -881,7 +883,8 @@ out:
883
return result;
884
}
885
884
-static int rm(int argc, const char **argv, const char *prefix)
886
+static int rm(int argc, const char **argv, const char *prefix,
887
+ struct repository *repo UNUSED)
888
{
889
struct option options[] = {
890
OPT_END()
@@ -1303,7 +1306,8 @@ static int show_all(void)
1306
return result;
1307
}
1308
1306
-static int show(int argc, const char **argv, const char *prefix)
1309
+static int show(int argc, const char **argv, const char *prefix,
1310
+ struct repository *repo UNUSED)
1311
{
1312
int no_query = 0, result = 0, query_flag = 0;
1313
struct option options[] = {
@@ -1399,7 +1403,8 @@ static int show(int argc, const char **argv, const char *prefix)
1403
return result;
1404
}
1405
1402
-static int set_head(int argc, const char **argv, const char *prefix)
1406
+static int set_head(int argc, const char **argv, const char *prefix,
1407
+ struct repository *repo UNUSED)
1408
{
1409
int i, opt_a = 0, opt_d = 0, result = 0;
1410
struct strbuf buf = STRBUF_INIT, buf2 = STRBUF_INIT;
@@ -1503,7 +1508,8 @@ static int prune_remote(const char *remote, int dry_run)
1508
return result;
1509
}
1510
1506
-static int prune(int argc, const char **argv, const char *prefix)
1511
+static int prune(int argc, const char **argv, const char *prefix,
1512
+ struct repository *repo UNUSED)
1513
{
1514
int dry_run = 0, result = 0;
1515
struct option options[] = {
@@ -1534,7 +1540,8 @@ static int get_remote_default(const char *key, const char *value UNUSED,
1540
return 0;
1541
}
1542
1537
-static int update(int argc, const char **argv, const char *prefix)
1543
+static int update(int argc, const char **argv, const char *prefix,
1544
+ struct repository *repo UNUSED)
1545
{
1546
int i, prune = -1;
1547
struct option options[] = {
@@ -1616,7 +1623,8 @@ static int set_remote_branches(const char *remotename, const char **branches,
1623
return 0;
1624
}
1625
1619
-static int set_branches(int argc, const char **argv, const char *prefix)
1626
+static int set_branches(int argc, const char **argv, const char *prefix,
1627
+ struct repository *repo UNUSED)
1628
{
1629
int add_mode = 0;
1630
struct option options[] = {
@@ -1635,7 +1643,8 @@ static int set_branches(int argc, const char **argv, const char *prefix)
1643
return set_remote_branches(argv[0], argv + 1, add_mode);
1644
}
1645
1638
-static int get_url(int argc, const char **argv, const char *prefix)
1646
+static int get_url(int argc, const char **argv, const char *prefix,
1647
+ struct repository *repo UNUSED)
1648
{
1649
int i, push_mode = 0, all_mode = 0;
1650
const char *remotename = NULL;
@@ -1674,7 +1683,8 @@ static int get_url(int argc, const char **argv, const char *prefix)
1683
return 0;
1684
}
1685
1677
-static int set_url(int argc, const char **argv, const char *prefix)
1686
+static int set_url(int argc, const char **argv, const char *prefix,
1687
+ struct repository *repo UNUSED)
1688
{
1689
int i, push_mode = 0, add_mode = 0, delete_mode = 0;
1690
int matches = 0, negative_matches = 0;
@@ -1765,7 +1775,7 @@ out:
1775
int cmd_remote(int argc,
1776
const char **argv,
1777
const char *prefix,
1768
- struct repository *repo UNUSED)
1778
+ struct repository *repo)
1779
{
1780
parse_opt_subcommand_fn *fn = NULL;
1781
struct option options[] = {
@@ -1788,7 +1798,7 @@ int cmd_remote(int argc,
1798
PARSE_OPT_SUBCOMMAND_OPTIONAL);
1799
1800
if (fn) {
1791
- return !!fn(argc, argv, prefix);
1801
+ return !!fn(argc, argv, prefix, repo);
1802
} else {
1803
if (argc) {
1804
error(_("unknown subcommand: `%s'"), argv[0]);
builtin/sparse-checkout.c
+16
-9
@@ -48,7 +48,8 @@ static char const * const builtin_sparse_checkout_list_usage[] = {
48
NULL
49
};
50
51
-static int sparse_checkout_list(int argc, const char **argv, const char *prefix)
51
+static int sparse_checkout_list(int argc, const char **argv, const char *prefix,
52
+ struct repository *repo UNUSED)
53
{
54
static struct option builtin_sparse_checkout_list_options[] = {
55
OPT_END(),
@@ -443,7 +444,8 @@ static struct sparse_checkout_init_opts {
444
int sparse_index;
445
} init_opts;
446
446
-static int sparse_checkout_init(int argc, const char **argv, const char *prefix)
447
+static int sparse_checkout_init(int argc, const char **argv, const char *prefix,
448
+ struct repository *repo UNUSED)
449
{
450
struct pattern_list pl;
451
char *sparse_filename;
@@ -770,7 +772,8 @@ static struct sparse_checkout_add_opts {
772
int use_stdin;
773
} add_opts;
774
773
-static int sparse_checkout_add(int argc, const char **argv, const char *prefix)
775
+static int sparse_checkout_add(int argc, const char **argv, const char *prefix,
776
+ struct repository *repo UNUSED)
777
{
778
static struct option builtin_sparse_checkout_add_options[] = {
779
OPT_BOOL_F(0, "skip-checks", &add_opts.skip_checks,
@@ -808,7 +811,8 @@ static struct sparse_checkout_set_opts {
811
int use_stdin;
812
} set_opts;
813
811
-static int sparse_checkout_set(int argc, const char **argv, const char *prefix)
814
+static int sparse_checkout_set(int argc, const char **argv, const char *prefix,
815
+ struct repository *repo UNUSED)
816
{
817
int default_patterns_nr = 2;
818
const char *default_patterns[] = {"/*", "!/*/", NULL};
@@ -866,7 +870,8 @@ static struct sparse_checkout_reapply_opts {
870
} reapply_opts;
871
872
static int sparse_checkout_reapply(int argc, const char **argv,
869
- const char *prefix)
873
+ const char *prefix,
874
+ struct repository *repo UNUSED)
875
{
876
static struct option builtin_sparse_checkout_reapply_options[] = {
877
OPT_BOOL(0, "cone", &reapply_opts.cone_mode,
@@ -901,7 +906,8 @@ static char const * const builtin_sparse_checkout_disable_usage[] = {
906
};
907
908
static int sparse_checkout_disable(int argc, const char **argv,
904
- const char *prefix)
909
+ const char *prefix,
910
+ struct repository *repo UNUSED)
911
{
912
static struct option builtin_sparse_checkout_disable_options[] = {
913
OPT_END(),
@@ -989,7 +995,8 @@ static int check_rules(struct pattern_list *pl, int null_terminated) {
995
return 0;
996
}
997
992
-static int sparse_checkout_check_rules(int argc, const char **argv, const char *prefix)
998
+static int sparse_checkout_check_rules(int argc, const char **argv, const char *prefix,
999
+ struct repository *repo UNUSED)
1000
{
1001
static struct option builtin_sparse_checkout_check_rules_options[] = {
1002
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 *
1044
int cmd_sparse_checkout(int argc,
1045
const char **argv,
1046
const char *prefix,
1040
- struct repository *repo UNUSED)
1047
+ struct repository *repo)
1048
{
1049
parse_opt_subcommand_fn *fn = NULL;
1050
struct option builtin_sparse_checkout_options[] = {
@@ -1060,5 +1067,5 @@ int cmd_sparse_checkout(int argc,
1067
prepare_repo_settings(the_repository);
1068
the_repository->settings.command_requires_full_index = 0;
1069
1063
- return fn(argc, argv, prefix);
1070
+ return fn(argc, argv, prefix, repo);
1071
}
builtin/stash.c
+25
-14
@@ -249,7 +249,8 @@ static int do_clear_stash(void)
249
ref_stash, &obj, 0);
250
}
251
252
-static int clear_stash(int argc, const char **argv, const char *prefix)
252
+static int clear_stash(int argc, const char **argv, const char *prefix,
253
+ struct repository *repo UNUSED)
254
{
255
struct option options[] = {
256
OPT_END()
@@ -652,7 +653,8 @@ restore_untracked:
653
return ret;
654
}
655
655
-static int apply_stash(int argc, const char **argv, const char *prefix)
656
+static int apply_stash(int argc, const char **argv, const char *prefix,
657
+ struct repository *repo UNUSED)
658
{
659
int ret = -1;
660
int quiet = 0;
@@ -726,7 +728,8 @@ static int get_stash_info_assert(struct stash_info *info, int argc,
728
return 0;
729
}
730
729
-static int drop_stash(int argc, const char **argv, const char *prefix)
731
+static int drop_stash(int argc, const char **argv, const char *prefix,
732
+ struct repository *repo UNUSED)
733
{
734
int ret = -1;
735
int quiet = 0;
@@ -748,7 +751,8 @@ cleanup:
751
return ret;
752
}
753
751
-static int pop_stash(int argc, const char **argv, const char *prefix)
754
+static int pop_stash(int argc, const char **argv, const char *prefix,
755
+ struct repository *repo UNUSED)
756
{
757
int ret = -1;
758
int index = 0;
@@ -778,7 +782,8 @@ cleanup:
782
return ret;
783
}
784
781
-static int branch_stash(int argc, const char **argv, const char *prefix)
785
+static int branch_stash(int argc, const char **argv, const char *prefix,
786
+ struct repository *repo UNUSED)
787
{
788
int ret = -1;
789
const char *branch = NULL;
@@ -816,7 +821,8 @@ cleanup:
821
return ret;
822
}
823
819
-static int list_stash(int argc, const char **argv, const char *prefix)
824
+static int list_stash(int argc, const char **argv, const char *prefix,
825
+ struct repository *repo UNUSED)
826
{
827
struct child_process cp = CHILD_PROCESS_INIT;
828
struct option options[] = {
@@ -889,7 +895,8 @@ static void diff_include_untracked(const struct stash_info *info, struct diff_op
895
do_diff_cache(&info->b_commit, diff_opt);
896
}
897
892
-static int show_stash(int argc, const char **argv, const char *prefix)
898
+static int show_stash(int argc, const char **argv, const char *prefix,
899
+ struct repository *repo UNUSED)
900
{
901
int i;
902
int ret = -1;
@@ -1017,7 +1024,8 @@ static int do_store_stash(const struct object_id *w_commit, const char *stash_ms
1024
return 0;
1025
}
1026
1020
-static int store_stash(int argc, const char **argv, const char *prefix)
1027
+static int store_stash(int argc, const char **argv, const char *prefix,
1028
+ struct repository *repo UNUSED)
1029
{
1030
int quiet = 0;
1031
const char *stash_msg = NULL;
@@ -1491,7 +1499,8 @@ done:
1499
return ret;
1500
}
1501
1494
-static int create_stash(int argc, const char **argv, const char *prefix UNUSED)
1502
+static int create_stash(int argc, const char **argv, const char *prefix UNUSED,
1503
+ struct repository *repo UNUSED)
1504
{
1505
int ret;
1506
struct strbuf stash_msg_buf = STRBUF_INIT;
@@ -1827,12 +1836,14 @@ static int push_stash(int argc, const char **argv, const char *prefix,
1836
return ret;
1837
}
1838
1830
-static int push_stash_unassumed(int argc, const char **argv, const char *prefix)
1839
+static int push_stash_unassumed(int argc, const char **argv, const char *prefix,
1840
+ struct repository *repo UNUSED)
1841
{
1842
return push_stash(argc, argv, prefix, 0);
1843
}
1844
1835
-static int save_stash(int argc, const char **argv, const char *prefix)
1845
+static int save_stash(int argc, const char **argv, const char *prefix,
1846
+ struct repository *repo UNUSED)
1847
{
1848
int keep_index = -1;
1849
int only_staged = 0;
@@ -1878,7 +1889,7 @@ static int save_stash(int argc, const char **argv, const char *prefix)
1889
int cmd_stash(int argc,
1890
const char **argv,
1891
const char *prefix,
1881
- struct repository *repo UNUSED)
1892
+ struct repository *repo)
1893
{
1894
pid_t pid = getpid();
1895
const char *index_file;
@@ -1916,9 +1927,9 @@ int cmd_stash(int argc,
1927
(uintmax_t)pid);
1928
1929
if (fn)
1919
- return !!fn(argc, argv, prefix);
1930
+ return !!fn(argc, argv, prefix, repo);
1931
else if (!argc)
1921
- return !!push_stash_unassumed(0, NULL, prefix);
1932
+ return !!push_stash_unassumed(0, NULL, prefix, repo);
1933
1934
/* Assume 'stash push' */
1935
strvec_push(&args, "push");
builtin/submodule--helper.c
+30
-16
@@ -399,7 +399,8 @@ cleanup:
399
free(displaypath);
400
}
401
402
-static int module_foreach(int argc, const char **argv, const char *prefix)
402
+static int module_foreach(int argc, const char **argv, const char *prefix,
403
+ struct repository *repo UNUSED)
404
{
405
struct foreach_cb info = FOREACH_CB_INIT;
406
struct pathspec pathspec = { 0 };
@@ -544,7 +545,8 @@ static void init_submodule_cb(const struct cache_entry *list_item, void *cb_data
545
info->flags);
546
}
547
547
-static int module_init(int argc, const char **argv, const char *prefix)
548
+static int module_init(int argc, const char **argv, const char *prefix,
549
+ struct repository *repo UNUSED)
550
{
551
struct init_cb info = INIT_CB_INIT;
552
struct pathspec pathspec = { 0 };
@@ -738,7 +740,8 @@ static void status_submodule_cb(const struct cache_entry *list_item,
740
info->prefix, info->super_prefix, info->flags);
741
}
742
741
-static int module_status(int argc, const char **argv, const char *prefix)
743
+static int module_status(int argc, const char **argv, const char *prefix,
744
+ struct repository *repo UNUSED)
745
{
746
struct status_cb info = STATUS_CB_INIT;
747
struct pathspec pathspec = { 0 };
@@ -1163,7 +1166,8 @@ cleanup:
1166
return ret;
1167
}
1168
1166
-static int module_summary(int argc, const char **argv, const char *prefix)
1169
+static int module_summary(int argc, const char **argv, const char *prefix,
1170
+ struct repository *repo UNUSED)
1171
{
1172
struct summary_cb info = SUMMARY_CB_INIT;
1173
int cached = 0;
@@ -1339,7 +1343,8 @@ static void sync_submodule_cb(const struct cache_entry *list_item, void *cb_data
1343
info->flags);
1344
}
1345
1342
-static int module_sync(int argc, const char **argv, const char *prefix)
1346
+static int module_sync(int argc, const char **argv, const char *prefix,
1347
+ struct repository *repo UNUSED)
1348
{
1349
struct sync_cb info = SYNC_CB_INIT;
1350
struct pathspec pathspec = { 0 };
@@ -1485,7 +1490,8 @@ static void deinit_submodule_cb(const struct cache_entry *list_item,
1490
deinit_submodule(list_item->name, info->prefix, info->flags);
1491
}
1492
1488
-static int module_deinit(int argc, const char **argv, const char *prefix)
1493
+static int module_deinit(int argc, const char **argv, const char *prefix,
1494
+ struct repository *repo UNUSED)
1495
{
1496
struct deinit_cb info = DEINIT_CB_INIT;
1497
struct pathspec pathspec = { 0 };
@@ -1842,7 +1848,8 @@ static int clone_submodule(const struct module_clone_data *clone_data,
1848
return 0;
1849
}
1850
1845
-static int module_clone(int argc, const char **argv, const char *prefix)
1851
+static int module_clone(int argc, const char **argv, const char *prefix,
1852
+ struct repository *repo UNUSED)
1853
{
1854
int dissociate = 0, quiet = 0, progress = 0, require_init = 0;
1855
struct module_clone_data clone_data = MODULE_CLONE_DATA_INIT;
@@ -2779,7 +2786,8 @@ cleanup:
2786
return ret;
2787
}
2788
2782
-static int module_update(int argc, const char **argv, const char *prefix)
2789
+static int module_update(int argc, const char **argv, const char *prefix,
2790
+ struct repository *repo UNUSED)
2791
{
2792
struct pathspec pathspec = { 0 };
2793
struct pathspec pathspec2 = { 0 };
@@ -2911,7 +2919,8 @@ cleanup:
2919
return ret;
2920
}
2921
2914
-static int push_check(int argc, const char **argv, const char *prefix UNUSED)
2922
+static int push_check(int argc, const char **argv, const char *prefix UNUSED,
2923
+ struct repository *repo UNUSED)
2924
{
2925
struct remote *remote;
2926
const char *superproject_head;
@@ -2991,7 +3000,8 @@ static int push_check(int argc, const char **argv, const char *prefix UNUSED)
3000
return 0;
3001
}
3002
2994
-static int absorb_git_dirs(int argc, const char **argv, const char *prefix)
3003
+static int absorb_git_dirs(int argc, const char **argv, const char *prefix,
3004
+ struct repository *repo UNUSED)
3005
{
3006
int i;
3007
struct pathspec pathspec = { 0 };
@@ -3024,7 +3034,8 @@ cleanup:
3034
return ret;
3035
}
3036
3027
-static int module_set_url(int argc, const char **argv, const char *prefix)
3037
+static int module_set_url(int argc, const char **argv, const char *prefix,
3038
+ struct repository *repo UNUSED)
3039
{
3040
int quiet = 0, ret;
3041
const char *newurl;
@@ -3063,7 +3074,8 @@ static int module_set_url(int argc, const char **argv, const char *prefix)
3074
return !!ret;
3075
}
3076
3066
-static int module_set_branch(int argc, const char **argv, const char *prefix)
3077
+static int module_set_branch(int argc, const char **argv, const char *prefix,
3078
+ struct repository *repo UNUSED)
3079
{
3080
int opt_default = 0, ret;
3081
const char *opt_branch = NULL;
@@ -3113,7 +3125,8 @@ static int module_set_branch(int argc, const char **argv, const char *prefix)
3125
return !!ret;
3126
}
3127
3116
-static int module_create_branch(int argc, const char **argv, const char *prefix)
3128
+static int module_create_branch(int argc, const char **argv, const char *prefix,
3129
+ struct repository *repo UNUSED)
3130
{
3131
enum branch_track track;
3132
int quiet = 0, force = 0, reflog = 0, dry_run = 0;
@@ -3424,7 +3437,8 @@ static void die_on_repo_without_commits(const char *path)
3437
strbuf_release(&sb);
3438
}
3439
3427
-static int module_add(int argc, const char **argv, const char *prefix)
3440
+static int module_add(int argc, const char **argv, const char *prefix,
3441
+ struct repository *repo UNUSED)
3442
{
3443
int force = 0, quiet = 0, progress = 0, dissociate = 0;
3444
struct add_data add_data = ADD_DATA_INIT;
@@ -3557,7 +3571,7 @@ cleanup:
3571
int cmd_submodule__helper(int argc,
3572
const char **argv,
3573
const char *prefix,
3560
- struct repository *repo UNUSED)
3574
+ struct repository *repo)
3575
{
3576
parse_opt_subcommand_fn *fn = NULL;
3577
const char *const usage[] = {
@@ -3583,5 +3597,5 @@ int cmd_submodule__helper(int argc,
3597
};
3598
argc = parse_options(argc, argv, prefix, options, usage, 0);
3599
3586
- return fn(argc, argv, prefix);
3600
+ return fn(argc, argv, prefix, repo);
3601
}
builtin/worktree.c
+18
-10
@@ -231,7 +231,8 @@ static void prune_worktrees(void)
231
strbuf_release(&reason);
232
}
233
234
-static int prune(int ac, const char **av, const char *prefix)
234
+static int prune(int ac, const char **av, const char *prefix,
235
+ struct repository *repo UNUSED)
236
{
237
struct option options[] = {
238
OPT__DRY_RUN(&show_only, N_("do not remove, show only")),
@@ -763,7 +764,8 @@ static char *dwim_branch(const char *path, char **new_branch)
764
return NULL;
765
}
766
766
-static int add(int ac, const char **av, const char *prefix)
767
+static int add(int ac, const char **av, const char *prefix,
768
+ struct repository *repo UNUSED)
769
{
770
struct add_opts opts;
771
const char *new_branch_force = NULL;
@@ -1039,7 +1041,8 @@ static void pathsort(struct worktree **wt)
1041
QSORT(wt, n, pathcmp);
1042
}
1043
1042
-static int list(int ac, const char **av, const char *prefix)
1044
+static int list(int ac, const char **av, const char *prefix,
1045
+ struct repository *repo UNUSED)
1046
{
1047
int porcelain = 0;
1048
int line_terminator = '\n';
@@ -1084,7 +1087,8 @@ static int list(int ac, const char **av, const char *prefix)
1087
return 0;
1088
}
1089
1087
-static int lock_worktree(int ac, const char **av, const char *prefix)
1090
+static int lock_worktree(int ac, const char **av, const char *prefix,
1091
+ struct repository *repo UNUSED)
1092
{
1093
const char *reason = "", *old_reason;
1094
struct option options[] = {
@@ -1119,7 +1123,8 @@ static int lock_worktree(int ac, const char **av, const char *prefix)
1123
return 0;
1124
}
1125
1122
-static int unlock_worktree(int ac, const char **av, const char *prefix)
1126
+static int unlock_worktree(int ac, const char **av, const char *prefix,
1127
+ struct repository *repo UNUSED)
1128
{
1129
struct option options[] = {
1130
OPT_END()
@@ -1182,7 +1187,8 @@ static void validate_no_submodules(const struct worktree *wt)
1187
die(_("working trees containing submodules cannot be moved or removed"));
1188
}
1189
1185
-static int move_worktree(int ac, const char **av, const char *prefix)
1190
+static int move_worktree(int ac, const char **av, const char *prefix,
1191
+ struct repository *repo UNUSED)
1192
{
1193
int force = 0;
1194
struct option options[] = {
@@ -1312,7 +1318,8 @@ static int delete_git_work_tree(struct worktree *wt)
1318
return ret;
1319
}
1320
1315
-static int remove_worktree(int ac, const char **av, const char *prefix)
1321
+static int remove_worktree(int ac, const char **av, const char *prefix,
1322
+ struct repository *repo UNUSED)
1323
{
1324
int force = 0;
1325
struct option options[] = {
@@ -1377,7 +1384,8 @@ static void report_repair(int iserr, const char *path, const char *msg, void *cb
1384
}
1385
}
1386
1380
-static int repair(int ac, const char **av, const char *prefix)
1387
+static int repair(int ac, const char **av, const char *prefix,
1388
+ struct repository *repo UNUSED)
1389
{
1390
const char **p;
1391
const char *self[] = { ".", NULL };
@@ -1397,7 +1405,7 @@ static int repair(int ac, const char **av, const char *prefix)
1405
int cmd_worktree(int ac,
1406
const char **av,
1407
const char *prefix,
1400
- struct repository *repo UNUSED)
1408
+ struct repository *repo)
1409
{
1410
parse_opt_subcommand_fn *fn = NULL;
1411
struct option options[] = {
@@ -1422,5 +1430,5 @@ int cmd_worktree(int ac,
1430
prepare_repo_settings(the_repository);
1431
the_repository->settings.command_requires_full_index = 0;
1432
1425
- return fn(ac, av, prefix);
1433
+ return fn(ac, av, prefix, repo);
1434
}
parse-options.h
+3
-1
@@ -3,6 +3,8 @@
3
4
#include "gettext.h"
5
6
+struct repository;
7
+
8
/**
9
* Refer to Documentation/technical/api-parse-options.txt for the API doc.
10
*/
@@ -73,7 +75,7 @@ typedef enum parse_opt_result parse_opt_ll_cb(struct parse_opt_ctx_t *ctx,
75
const char *arg, int unset);
76
77
typedef int parse_opt_subcommand_fn(int argc, const char **argv,
76
- const char *prefix);
78
+ const char *prefix, struct repository *repo);
79
80
/*
81
* `type`::
t/helper/test-parse-options.c
+5
-3
@@ -282,14 +282,16 @@ int cmd__parse_options_flags(int argc, const char **argv)
282
return parse_options_flags__cmd(argc, argv, test_flags);
283
}
284
285
-static int subcmd_one(int argc, const char **argv, const char *prefix UNUSED)
285
+static int subcmd_one(int argc, const char **argv, const char *prefix UNUSED,
286
+ struct repository *repo UNUSED)
287
{
288
printf("fn: subcmd_one\n");
289
print_args(argc, argv);
290
return 0;
291
}
292
292
-static int subcmd_two(int argc, const char **argv, const char *prefix UNUSED)
293
+static int subcmd_two(int argc, const char **argv, const char *prefix UNUSED,
294
+ struct repository *repo UNUSED)
295
{
296
printf("fn: subcmd_two\n");
297
print_args(argc, argv);
@@ -319,7 +321,7 @@ static int parse_subcommand__cmd(int argc, const char **argv,
321
322
printf("opt: %d\n", opt);
323
322
- return fn(argc, argv, NULL);
324
+ return fn(argc, argv, NULL, NULL);
325
}
326
327
int cmd__parse_subcommand(int argc, const char **argv)