Skip to content

Commit 9920c4b

Browse files
committed
Merge branch 'kn/midx-wo-the-repository' into seen
* kn/midx-wo-the-repository: midx: inline the `MIDX_MIN_SIZE` definition midx: pass down `hash_algo` to `get_split_midx_filename_ext` midx: pass down `hash_algo` to `get_midx_filename[_ext]` midx: pass `repository` to `load_multi_pack_index` midx: cleanup internal usage of `the_repository` and `the_hash_algo` midx-write: pass down repository to `write_midx_file[_only]` write-midx: add repository field to `write_midx_context` midx-write: use `revs->repo` inside `read_refs_snapshot` midx-write: pass down repository to static functions builtin: pass repository to sub commands
2 parents c354f3a + c3f68ce commit 9920c4b

24 files changed

+389
-262
lines changed

builtin/bisect.c

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1312,15 +1312,17 @@ static int bisect_run(struct bisect_terms *terms, int argc, const char **argv)
13121312
return res;
13131313
}
13141314

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)
13161317
{
13171318
if (argc > 1)
13181319
return error(_("'%s' requires either no argument or a commit"),
13191320
"git bisect reset");
13201321
return bisect_reset(argc ? argv[0] : NULL);
13211322
}
13221323

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)
13241326
{
13251327
int res;
13261328
struct bisect_terms terms = { 0 };
@@ -1333,7 +1335,8 @@ static int cmd_bisect__terms(int argc, const char **argv, const char *prefix UNU
13331335
return res;
13341336
}
13351337

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)
13371340
{
13381341
int res;
13391342
struct bisect_terms terms = { 0 };
@@ -1344,7 +1347,8 @@ static int cmd_bisect__start(int argc, const char **argv, const char *prefix UNU
13441347
return res;
13451348
}
13461349

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)
13481352
{
13491353
int res;
13501354
struct bisect_terms terms = { 0 };
@@ -1358,12 +1362,15 @@ static int cmd_bisect__next(int argc, const char **argv UNUSED, const char *pref
13581362
return res;
13591363
}
13601364

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)
13621368
{
13631369
return bisect_log();
13641370
}
13651371

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)
13671374
{
13681375
int res;
13691376
struct bisect_terms terms = { 0 };
@@ -1376,7 +1383,8 @@ static int cmd_bisect__replay(int argc, const char **argv, const char *prefix UN
13761383
return res;
13771384
}
13781385

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)
13801388
{
13811389
int res;
13821390
struct bisect_terms terms = { 0 };
@@ -1388,7 +1396,8 @@ static int cmd_bisect__skip(int argc, const char **argv, const char *prefix UNUS
13881396
return res;
13891397
}
13901398

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)
13921401
{
13931402
int res;
13941403
struct bisect_terms terms = { 0 };
@@ -1399,7 +1408,8 @@ static int cmd_bisect__visualize(int argc, const char **argv, const char *prefix
13991408
return res;
14001409
}
14011410

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)
14031413
{
14041414
int res;
14051415
struct bisect_terms terms = { 0 };
@@ -1415,7 +1425,7 @@ static int cmd_bisect__run(int argc, const char **argv, const char *prefix UNUSE
14151425
int cmd_bisect(int argc,
14161426
const char **argv,
14171427
const char *prefix,
1418-
struct repository *repo UNUSED)
1428+
struct repository *repo)
14191429
{
14201430
int res = 0;
14211431
parse_opt_subcommand_fn *fn = NULL;
@@ -1451,7 +1461,7 @@ int cmd_bisect(int argc,
14511461
} else {
14521462
argc--;
14531463
argv++;
1454-
res = fn(argc, argv, prefix);
1464+
res = fn(argc, argv, prefix, repo);
14551465
}
14561466

14571467
return is_bisect_success(res) ? 0 : -res;

builtin/bundle.c

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,8 @@ static int parse_options_cmd_bundle(int argc,
6767
return argc;
6868
}
6969

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) {
7172
struct strvec pack_opts = STRVEC_INIT;
7273
int version = -1;
7374
int ret;
@@ -123,7 +124,8 @@ static int open_bundle(const char *path, struct bundle_header *header,
123124
return read_bundle_header(path, header);
124125
}
125126

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) {
127129
struct bundle_header header = BUNDLE_HEADER_INIT;
128130
int bundle_fd = -1;
129131
int quiet = 0;
@@ -164,7 +166,8 @@ static int cmd_bundle_verify(int argc, const char **argv, const char *prefix) {
164166
return ret;
165167
}
166168

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) {
168171
struct bundle_header header = BUNDLE_HEADER_INIT;
169172
int bundle_fd = -1;
170173
int ret;
@@ -189,7 +192,8 @@ static int cmd_bundle_list_heads(int argc, const char **argv, const char *prefix
189192
return ret;
190193
}
191194

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) {
193197
struct bundle_header header = BUNDLE_HEADER_INIT;
194198
int bundle_fd = -1;
195199
int ret;
@@ -231,7 +235,7 @@ static int cmd_bundle_unbundle(int argc, const char **argv, const char *prefix)
231235
int cmd_bundle(int argc,
232236
const char **argv,
233237
const char *prefix,
234-
struct repository *repo UNUSED)
238+
struct repository *repo)
235239
{
236240
parse_opt_subcommand_fn *fn = NULL;
237241
struct option options[] = {
@@ -247,5 +251,5 @@ int cmd_bundle(int argc,
247251

248252
packet_trace_identity("bundle");
249253

250-
return !!fn(argc, argv, prefix);
254+
return !!fn(argc, argv, prefix, repo);
251255
}

builtin/commit-graph.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,8 @@ static struct option *add_common_options(struct option *to)
6262
return parse_options_concat(common_opts, to);
6363
}
6464

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)
6667
{
6768
struct commit_graph *graph = NULL;
6869
struct object_directory *odb = NULL;
@@ -214,7 +215,8 @@ static int git_commit_graph_write_config(const char *var, const char *value,
214215
return 0;
215216
}
216217

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)
218220
{
219221
struct string_list pack_indexes = STRING_LIST_INIT_DUP;
220222
struct strbuf buf = STRBUF_INIT;
@@ -333,7 +335,7 @@ static int graph_write(int argc, const char **argv, const char *prefix)
333335
int cmd_commit_graph(int argc,
334336
const char **argv,
335337
const char *prefix,
336-
struct repository *repo UNUSED)
338+
struct repository *repo)
337339
{
338340
parse_opt_subcommand_fn *fn = NULL;
339341
struct option builtin_commit_graph_options[] = {
@@ -352,5 +354,5 @@ int cmd_commit_graph(int argc,
352354
builtin_commit_graph_usage, 0);
353355
FREE_AND_NULL(options);
354356

355-
return fn(argc, argv, prefix);
357+
return fn(argc, argv, prefix, repo);
356358
}

builtin/config.c

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -826,7 +826,8 @@ static void display_options_init(struct config_display_options *opts)
826826
}
827827
}
828828

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)
830831
{
831832
struct config_location_options location_opts = CONFIG_LOCATION_OPTIONS_INIT;
832833
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)
861862
return 0;
862863
}
863864

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)
865867
{
866868
struct config_location_options location_opts = CONFIG_LOCATION_OPTIONS_INIT;
867869
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)
915917
return ret;
916918
}
917919

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)
919922
{
920923
struct config_location_options location_opts = CONFIG_LOCATION_OPTIONS_INIT;
921924
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)
973976
return ret;
974977
}
975978

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)
977981
{
978982
struct config_location_options location_opts = CONFIG_LOCATION_OPTIONS_INIT;
979983
const char *value_pattern = NULL;
@@ -1010,7 +1014,8 @@ static int cmd_config_unset(int argc, const char **argv, const char *prefix)
10101014
return ret;
10111015
}
10121016

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)
10141019
{
10151020
struct config_location_options location_opts = CONFIG_LOCATION_OPTIONS_INIT;
10161021
struct option opts[] = {
@@ -1039,7 +1044,8 @@ static int cmd_config_rename_section(int argc, const char **argv, const char *pr
10391044
return ret;
10401045
}
10411046

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)
10431049
{
10441050
struct config_location_options location_opts = CONFIG_LOCATION_OPTIONS_INIT;
10451051
struct option opts[] = {
@@ -1099,7 +1105,8 @@ static int show_editor(struct config_location_options *opts)
10991105
return 0;
11001106
}
11011107

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)
11031110
{
11041111
struct config_location_options location_opts = CONFIG_LOCATION_OPTIONS_INIT;
11051112
struct option opts[] = {
@@ -1395,7 +1402,7 @@ static int cmd_config_actions(int argc, const char **argv, const char *prefix)
13951402
int cmd_config(int argc,
13961403
const char **argv,
13971404
const char *prefix,
1398-
struct repository *repo UNUSED)
1405+
struct repository *repo)
13991406
{
14001407
parse_opt_subcommand_fn *subcommand = NULL;
14011408
struct option subcommand_opts[] = {
@@ -1422,7 +1429,7 @@ int cmd_config(int argc,
14221429
if (subcommand) {
14231430
argc = parse_options(argc, argv, prefix, subcommand_opts, builtin_config_usage,
14241431
PARSE_OPT_SUBCOMMAND_OPTIONAL|PARSE_OPT_KEEP_UNKNOWN_OPT);
1425-
return subcommand(argc, argv, prefix);
1432+
return subcommand(argc, argv, prefix, repo);
14261433
}
14271434

14281435
return cmd_config_actions(argc, argv, prefix);

builtin/gc.c

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1567,7 +1567,8 @@ static int task_option_parse(const struct option *opt UNUSED,
15671567
return 0;
15681568
}
15691569

1570-
static int maintenance_run(int argc, const char **argv, const char *prefix)
1570+
static int maintenance_run(int argc, const char **argv, const char *prefix,
1571+
struct repository *repo UNUSED)
15711572
{
15721573
int i;
15731574
struct maintenance_run_opts opts = MAINTENANCE_RUN_OPTS_INIT;
@@ -1629,7 +1630,8 @@ static char const * const builtin_maintenance_register_usage[] = {
16291630
NULL
16301631
};
16311632

1632-
static int maintenance_register(int argc, const char **argv, const char *prefix)
1633+
static int maintenance_register(int argc, const char **argv, const char *prefix,
1634+
struct repository *repo UNUSED)
16331635
{
16341636
char *config_file = NULL;
16351637
struct option options[] = {
@@ -1693,7 +1695,8 @@ static char const * const builtin_maintenance_unregister_usage[] = {
16931695
NULL
16941696
};
16951697

1696-
static int maintenance_unregister(int argc, const char **argv, const char *prefix)
1698+
static int maintenance_unregister(int argc, const char **argv, const char *prefix,
1699+
struct repository *repo UNUSED)
16971700
{
16981701
int force = 0;
16991702
char *config_file = NULL;
@@ -2932,7 +2935,8 @@ static const char *const builtin_maintenance_start_usage[] = {
29322935
NULL
29332936
};
29342937

2935-
static int maintenance_start(int argc, const char **argv, const char *prefix)
2938+
static int maintenance_start(int argc, const char **argv, const char *prefix,
2939+
struct repository *repo)
29362940
{
29372941
struct maintenance_start_opts opts = { 0 };
29382942
struct option options[] = {
@@ -2955,7 +2959,7 @@ static int maintenance_start(int argc, const char **argv, const char *prefix)
29552959
if (update_background_schedule(&opts, 1))
29562960
die(_("failed to set up maintenance schedule"));
29572961

2958-
if (maintenance_register(ARRAY_SIZE(register_args)-1, register_args, NULL))
2962+
if (maintenance_register(ARRAY_SIZE(register_args)-1, register_args, NULL, repo))
29592963
warning(_("failed to add repo to global config"));
29602964
return 0;
29612965
}
@@ -2965,7 +2969,8 @@ static const char *const builtin_maintenance_stop_usage[] = {
29652969
NULL
29662970
};
29672971

2968-
static int maintenance_stop(int argc, const char **argv, const char *prefix)
2972+
static int maintenance_stop(int argc, const char **argv, const char *prefix,
2973+
struct repository *repo UNUSED)
29692974
{
29702975
struct option options[] = {
29712976
OPT_END()
@@ -2985,7 +2990,7 @@ static const char * const builtin_maintenance_usage[] = {
29852990
int cmd_maintenance(int argc,
29862991
const char **argv,
29872992
const char *prefix,
2988-
struct repository *repo UNUSED)
2993+
struct repository *repo)
29892994
{
29902995
parse_opt_subcommand_fn *fn = NULL;
29912996
struct option builtin_maintenance_options[] = {
@@ -2999,5 +3004,5 @@ int cmd_maintenance(int argc,
29993004

30003005
argc = parse_options(argc, argv, prefix, builtin_maintenance_options,
30013006
builtin_maintenance_usage, 0);
3002-
return fn(argc, argv, prefix);
3007+
return fn(argc, argv, prefix, repo);
30033008
}

builtin/hook.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ static const char * const builtin_hook_run_usage[] = {
1919
NULL
2020
};
2121

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)
2324
{
2425
int i;
2526
struct run_hooks_opt opt = RUN_HOOKS_OPT_INIT;
@@ -70,7 +71,7 @@ static int run(int argc, const char **argv, const char *prefix)
7071
int cmd_hook(int argc,
7172
const char **argv,
7273
const char *prefix,
73-
struct repository *repo UNUSED)
74+
struct repository *repo)
7475
{
7576
parse_opt_subcommand_fn *fn = NULL;
7677
struct option builtin_hook_options[] = {
@@ -81,5 +82,5 @@ int cmd_hook(int argc,
8182
argc = parse_options(argc, argv, NULL, builtin_hook_options,
8283
builtin_hook_usage, 0);
8384

84-
return fn(argc, argv, prefix);
85+
return fn(argc, argv, prefix, repo);
8586
}

0 commit comments

Comments
 (0)