Skip to content

Commit

Permalink
Merge branch 'kn/midx-wo-the-repository' into seen
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
gitster committed Nov 22, 2024
2 parents c354f3a + c3f68ce commit 9920c4b
Show file tree
Hide file tree
Showing 24 changed files with 389 additions and 262 deletions.
32 changes: 21 additions & 11 deletions builtin/bisect.c
Original file line number Diff line number Diff line change
Expand Up @@ -1312,15 +1312,17 @@ static int bisect_run(struct bisect_terms *terms, int argc, const char **argv)
return res;
}

static int cmd_bisect__reset(int argc, const char **argv, const char *prefix UNUSED)
static int cmd_bisect__reset(int argc, const char **argv, const char *prefix UNUSED,
struct repository *repo UNUSED)
{
if (argc > 1)
return error(_("'%s' requires either no argument or a commit"),
"git bisect reset");
return bisect_reset(argc ? argv[0] : NULL);
}

static int cmd_bisect__terms(int argc, const char **argv, const char *prefix UNUSED)
static int cmd_bisect__terms(int argc, const char **argv, const char *prefix UNUSED,
struct repository *repo UNUSED)
{
int res;
struct bisect_terms terms = { 0 };
Expand All @@ -1333,7 +1335,8 @@ static int cmd_bisect__terms(int argc, const char **argv, const char *prefix UNU
return res;
}

static int cmd_bisect__start(int argc, const char **argv, const char *prefix UNUSED)
static int cmd_bisect__start(int argc, const char **argv, const char *prefix UNUSED,
struct repository *repo UNUSED)
{
int res;
struct bisect_terms terms = { 0 };
Expand All @@ -1344,7 +1347,8 @@ static int cmd_bisect__start(int argc, const char **argv, const char *prefix UNU
return res;
}

static int cmd_bisect__next(int argc, const char **argv UNUSED, const char *prefix)
static int cmd_bisect__next(int argc, const char **argv UNUSED, const char *prefix,
struct repository *repo UNUSED)
{
int res;
struct bisect_terms terms = { 0 };
Expand All @@ -1358,12 +1362,15 @@ static int cmd_bisect__next(int argc, const char **argv UNUSED, const char *pref
return res;
}

static int cmd_bisect__log(int argc UNUSED, const char **argv UNUSED, const char *prefix UNUSED)
static int cmd_bisect__log(int argc UNUSED, const char **argv UNUSED,
const char *prefix UNUSED,
struct repository *repo UNUSED)
{
return bisect_log();
}

static int cmd_bisect__replay(int argc, const char **argv, const char *prefix UNUSED)
static int cmd_bisect__replay(int argc, const char **argv, const char *prefix UNUSED,
struct repository *repo UNUSED)
{
int res;
struct bisect_terms terms = { 0 };
Expand All @@ -1376,7 +1383,8 @@ static int cmd_bisect__replay(int argc, const char **argv, const char *prefix UN
return res;
}

static int cmd_bisect__skip(int argc, const char **argv, const char *prefix UNUSED)
static int cmd_bisect__skip(int argc, const char **argv, const char *prefix UNUSED,
struct repository *repo UNUSED)
{
int res;
struct bisect_terms terms = { 0 };
Expand All @@ -1388,7 +1396,8 @@ static int cmd_bisect__skip(int argc, const char **argv, const char *prefix UNUS
return res;
}

static int cmd_bisect__visualize(int argc, const char **argv, const char *prefix UNUSED)
static int cmd_bisect__visualize(int argc, const char **argv, const char *prefix UNUSED,
struct repository *repo UNUSED)
{
int res;
struct bisect_terms terms = { 0 };
Expand All @@ -1399,7 +1408,8 @@ static int cmd_bisect__visualize(int argc, const char **argv, const char *prefix
return res;
}

static int cmd_bisect__run(int argc, const char **argv, const char *prefix UNUSED)
static int cmd_bisect__run(int argc, const char **argv, const char *prefix UNUSED,
struct repository *repo UNUSED)
{
int res;
struct bisect_terms terms = { 0 };
Expand All @@ -1415,7 +1425,7 @@ static int cmd_bisect__run(int argc, const char **argv, const char *prefix UNUSE
int cmd_bisect(int argc,
const char **argv,
const char *prefix,
struct repository *repo UNUSED)
struct repository *repo)
{
int res = 0;
parse_opt_subcommand_fn *fn = NULL;
Expand Down Expand Up @@ -1451,7 +1461,7 @@ int cmd_bisect(int argc,
} else {
argc--;
argv++;
res = fn(argc, argv, prefix);
res = fn(argc, argv, prefix, repo);
}

return is_bisect_success(res) ? 0 : -res;
Expand Down
16 changes: 10 additions & 6 deletions builtin/bundle.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ static int parse_options_cmd_bundle(int argc,
return argc;
}

static int cmd_bundle_create(int argc, const char **argv, const char *prefix) {
static int cmd_bundle_create(int argc, const char **argv, const char *prefix,
struct repository *repo UNUSED) {
struct strvec pack_opts = STRVEC_INIT;
int version = -1;
int ret;
Expand Down Expand Up @@ -123,7 +124,8 @@ static int open_bundle(const char *path, struct bundle_header *header,
return read_bundle_header(path, header);
}

static int cmd_bundle_verify(int argc, const char **argv, const char *prefix) {
static int cmd_bundle_verify(int argc, const char **argv, const char *prefix,
struct repository *repo UNUSED) {
struct bundle_header header = BUNDLE_HEADER_INIT;
int bundle_fd = -1;
int quiet = 0;
Expand Down Expand Up @@ -164,7 +166,8 @@ static int cmd_bundle_verify(int argc, const char **argv, const char *prefix) {
return ret;
}

static int cmd_bundle_list_heads(int argc, const char **argv, const char *prefix) {
static int cmd_bundle_list_heads(int argc, const char **argv, const char *prefix,
struct repository *repo UNUSED) {
struct bundle_header header = BUNDLE_HEADER_INIT;
int bundle_fd = -1;
int ret;
Expand All @@ -189,7 +192,8 @@ static int cmd_bundle_list_heads(int argc, const char **argv, const char *prefix
return ret;
}

static int cmd_bundle_unbundle(int argc, const char **argv, const char *prefix) {
static int cmd_bundle_unbundle(int argc, const char **argv, const char *prefix,
struct repository *repo UNUSED) {
struct bundle_header header = BUNDLE_HEADER_INIT;
int bundle_fd = -1;
int ret;
Expand Down Expand Up @@ -231,7 +235,7 @@ static int cmd_bundle_unbundle(int argc, const char **argv, const char *prefix)
int cmd_bundle(int argc,
const char **argv,
const char *prefix,
struct repository *repo UNUSED)
struct repository *repo)
{
parse_opt_subcommand_fn *fn = NULL;
struct option options[] = {
Expand All @@ -247,5 +251,5 @@ int cmd_bundle(int argc,

packet_trace_identity("bundle");

return !!fn(argc, argv, prefix);
return !!fn(argc, argv, prefix, repo);
}
10 changes: 6 additions & 4 deletions builtin/commit-graph.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ static struct option *add_common_options(struct option *to)
return parse_options_concat(common_opts, to);
}

static int graph_verify(int argc, const char **argv, const char *prefix)
static int graph_verify(int argc, const char **argv, const char *prefix,
struct repository *repo UNUSED)
{
struct commit_graph *graph = NULL;
struct object_directory *odb = NULL;
Expand Down Expand Up @@ -214,7 +215,8 @@ static int git_commit_graph_write_config(const char *var, const char *value,
return 0;
}

static int graph_write(int argc, const char **argv, const char *prefix)
static int graph_write(int argc, const char **argv, const char *prefix,
struct repository *repo UNUSED)
{
struct string_list pack_indexes = STRING_LIST_INIT_DUP;
struct strbuf buf = STRBUF_INIT;
Expand Down Expand Up @@ -333,7 +335,7 @@ static int graph_write(int argc, const char **argv, const char *prefix)
int cmd_commit_graph(int argc,
const char **argv,
const char *prefix,
struct repository *repo UNUSED)
struct repository *repo)
{
parse_opt_subcommand_fn *fn = NULL;
struct option builtin_commit_graph_options[] = {
Expand All @@ -352,5 +354,5 @@ int cmd_commit_graph(int argc,
builtin_commit_graph_usage, 0);
FREE_AND_NULL(options);

return fn(argc, argv, prefix);
return fn(argc, argv, prefix, repo);
}
25 changes: 16 additions & 9 deletions builtin/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -826,7 +826,8 @@ static void display_options_init(struct config_display_options *opts)
}
}

static int cmd_config_list(int argc, const char **argv, const char *prefix)
static int cmd_config_list(int argc, const char **argv, const char *prefix,
struct repository *repo UNUSED)
{
struct config_location_options location_opts = CONFIG_LOCATION_OPTIONS_INIT;
struct config_display_options display_opts = CONFIG_DISPLAY_OPTIONS_INIT;
Expand Down Expand Up @@ -861,7 +862,8 @@ static int cmd_config_list(int argc, const char **argv, const char *prefix)
return 0;
}

static int cmd_config_get(int argc, const char **argv, const char *prefix)
static int cmd_config_get(int argc, const char **argv, const char *prefix,
struct repository *repo UNUSED)
{
struct config_location_options location_opts = CONFIG_LOCATION_OPTIONS_INIT;
struct config_display_options display_opts = CONFIG_DISPLAY_OPTIONS_INIT;
Expand Down Expand Up @@ -915,7 +917,8 @@ static int cmd_config_get(int argc, const char **argv, const char *prefix)
return ret;
}

static int cmd_config_set(int argc, const char **argv, const char *prefix)
static int cmd_config_set(int argc, const char **argv, const char *prefix,
struct repository *repo UNUSED)
{
struct config_location_options location_opts = CONFIG_LOCATION_OPTIONS_INIT;
const char *value_pattern = NULL, *comment_arg = NULL;
Expand Down Expand Up @@ -973,7 +976,8 @@ static int cmd_config_set(int argc, const char **argv, const char *prefix)
return ret;
}

static int cmd_config_unset(int argc, const char **argv, const char *prefix)
static int cmd_config_unset(int argc, const char **argv, const char *prefix,
struct repository *repo UNUSED)
{
struct config_location_options location_opts = CONFIG_LOCATION_OPTIONS_INIT;
const char *value_pattern = NULL;
Expand Down Expand Up @@ -1010,7 +1014,8 @@ static int cmd_config_unset(int argc, const char **argv, const char *prefix)
return ret;
}

static int cmd_config_rename_section(int argc, const char **argv, const char *prefix)
static int cmd_config_rename_section(int argc, const char **argv, const char *prefix,
struct repository *repo UNUSED)
{
struct config_location_options location_opts = CONFIG_LOCATION_OPTIONS_INIT;
struct option opts[] = {
Expand Down Expand Up @@ -1039,7 +1044,8 @@ static int cmd_config_rename_section(int argc, const char **argv, const char *pr
return ret;
}

static int cmd_config_remove_section(int argc, const char **argv, const char *prefix)
static int cmd_config_remove_section(int argc, const char **argv, const char *prefix,
struct repository *repo UNUSED)
{
struct config_location_options location_opts = CONFIG_LOCATION_OPTIONS_INIT;
struct option opts[] = {
Expand Down Expand Up @@ -1099,7 +1105,8 @@ static int show_editor(struct config_location_options *opts)
return 0;
}

static int cmd_config_edit(int argc, const char **argv, const char *prefix)
static int cmd_config_edit(int argc, const char **argv, const char *prefix,
struct repository *repo UNUSED)
{
struct config_location_options location_opts = CONFIG_LOCATION_OPTIONS_INIT;
struct option opts[] = {
Expand Down Expand Up @@ -1395,7 +1402,7 @@ static int cmd_config_actions(int argc, const char **argv, const char *prefix)
int cmd_config(int argc,
const char **argv,
const char *prefix,
struct repository *repo UNUSED)
struct repository *repo)
{
parse_opt_subcommand_fn *subcommand = NULL;
struct option subcommand_opts[] = {
Expand All @@ -1422,7 +1429,7 @@ int cmd_config(int argc,
if (subcommand) {
argc = parse_options(argc, argv, prefix, subcommand_opts, builtin_config_usage,
PARSE_OPT_SUBCOMMAND_OPTIONAL|PARSE_OPT_KEEP_UNKNOWN_OPT);
return subcommand(argc, argv, prefix);
return subcommand(argc, argv, prefix, repo);
}

return cmd_config_actions(argc, argv, prefix);
Expand Down
21 changes: 13 additions & 8 deletions builtin/gc.c
Original file line number Diff line number Diff line change
Expand Up @@ -1567,7 +1567,8 @@ static int task_option_parse(const struct option *opt UNUSED,
return 0;
}

static int maintenance_run(int argc, const char **argv, const char *prefix)
static int maintenance_run(int argc, const char **argv, const char *prefix,
struct repository *repo UNUSED)
{
int i;
struct maintenance_run_opts opts = MAINTENANCE_RUN_OPTS_INIT;
Expand Down Expand Up @@ -1629,7 +1630,8 @@ static char const * const builtin_maintenance_register_usage[] = {
NULL
};

static int maintenance_register(int argc, const char **argv, const char *prefix)
static int maintenance_register(int argc, const char **argv, const char *prefix,
struct repository *repo UNUSED)
{
char *config_file = NULL;
struct option options[] = {
Expand Down Expand Up @@ -1693,7 +1695,8 @@ static char const * const builtin_maintenance_unregister_usage[] = {
NULL
};

static int maintenance_unregister(int argc, const char **argv, const char *prefix)
static int maintenance_unregister(int argc, const char **argv, const char *prefix,
struct repository *repo UNUSED)
{
int force = 0;
char *config_file = NULL;
Expand Down Expand Up @@ -2932,7 +2935,8 @@ static const char *const builtin_maintenance_start_usage[] = {
NULL
};

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

if (maintenance_register(ARRAY_SIZE(register_args)-1, register_args, NULL))
if (maintenance_register(ARRAY_SIZE(register_args)-1, register_args, NULL, repo))
warning(_("failed to add repo to global config"));
return 0;
}
Expand All @@ -2965,7 +2969,8 @@ static const char *const builtin_maintenance_stop_usage[] = {
NULL
};

static int maintenance_stop(int argc, const char **argv, const char *prefix)
static int maintenance_stop(int argc, const char **argv, const char *prefix,
struct repository *repo UNUSED)
{
struct option options[] = {
OPT_END()
Expand All @@ -2985,7 +2990,7 @@ static const char * const builtin_maintenance_usage[] = {
int cmd_maintenance(int argc,
const char **argv,
const char *prefix,
struct repository *repo UNUSED)
struct repository *repo)
{
parse_opt_subcommand_fn *fn = NULL;
struct option builtin_maintenance_options[] = {
Expand All @@ -2999,5 +3004,5 @@ int cmd_maintenance(int argc,

argc = parse_options(argc, argv, prefix, builtin_maintenance_options,
builtin_maintenance_usage, 0);
return fn(argc, argv, prefix);
return fn(argc, argv, prefix, repo);
}
7 changes: 4 additions & 3 deletions builtin/hook.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ static const char * const builtin_hook_run_usage[] = {
NULL
};

static int run(int argc, const char **argv, const char *prefix)
static int run(int argc, const char **argv, const char *prefix,
struct repository *repo UNUSED)
{
int i;
struct run_hooks_opt opt = RUN_HOOKS_OPT_INIT;
Expand Down Expand Up @@ -70,7 +71,7 @@ static int run(int argc, const char **argv, const char *prefix)
int cmd_hook(int argc,
const char **argv,
const char *prefix,
struct repository *repo UNUSED)
struct repository *repo)
{
parse_opt_subcommand_fn *fn = NULL;
struct option builtin_hook_options[] = {
Expand All @@ -81,5 +82,5 @@ int cmd_hook(int argc,
argc = parse_options(argc, argv, NULL, builtin_hook_options,
builtin_hook_usage, 0);

return fn(argc, argv, prefix);
return fn(argc, argv, prefix, repo);
}
Loading

0 comments on commit 9920c4b

Please sign in to comment.