[PATCH v5 1/2] pack-objects: give fetch_if_missing call sites access to 'repo'
Tian Yuchen <[email protected]>
| Newsgroups | org.kernel.vger.git |
|---|---|
| Message-ID | <[email protected]> |
In order to move the global 'fetch_if_missing' variable into 'struct repository' in a follow-up commit, first make sure every call site in builtin/pack-objects.c has a 'struct repository *'. 'cmd_pack_objects()' already receives a 'repo' parameter. Drop the UNUSED mark. 'option_parse_missing_action()' is registered as an OPT_CALLBACK, so its signature is fixed and cannot easily gain a 'repo' parameter of its own. Let it only record 'arg_missing_action'. Instead, apply the side effect right after 'parse_options()' returns in 'cmd_pack_objects()', where 'repo' is available. Mentored-by: Christian Couder <[email protected]> Mentored-by: Ayush Chandekar <[email protected]> Mentored-by: Olamide Caleb Bello <[email protected]> Signed-off-by: Tian Yuchen <[email protected]> --- builtin/pack-objects.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/builtin/pack-objects.c b/builtin/pack-objects.c index 1ec5b6f206..2b14dd2f31 100644 --- a/builtin/pack-objects.c +++ b/builtin/pack-objects.c @@ -4087,7 +4087,8 @@ static void stdin_packs_read_input(struct rev_info *revs, static void add_unreachable_loose_objects(struct rev_info *revs); -static void read_stdin_packs(enum stdin_packs_mode mode, int rev_list_unpacked) +static void read_stdin_packs(struct repository *repo, + enum stdin_packs_mode mode, int rev_list_unpacked) { int prev_fetch_if_missing = fetch_if_missing; struct rev_info revs; @@ -4099,7 +4100,7 @@ static void read_stdin_packs(enum stdin_packs_mode mode, int rev_list_unpacked) */ fetch_if_missing = 0; - repo_init_revisions(the_repository, &revs, NULL); + repo_init_revisions(repo, &revs, NULL); /* * Use a revision walk to fill in the namehash of objects in the include * packs. To save time, we'll avoid traversing through objects that are @@ -4469,14 +4470,12 @@ static int option_parse_missing_action(const struct option *opt UNUSED, if (!strcmp(arg, "allow-any")) { arg_missing_action = MA_ALLOW_ANY; - fetch_if_missing = 0; fn_show_object = show_object__ma_allow_any; return 0; } if (!strcmp(arg, "allow-promisor")) { arg_missing_action = MA_ALLOW_PROMISOR; - fetch_if_missing = 0; fn_show_object = show_object__ma_allow_promisor; return 0; } @@ -5118,7 +5117,7 @@ static int parse_stdin_packs_mode(const struct option *opt, const char *arg, int cmd_pack_objects(int argc, const char **argv, const char *prefix, - struct repository *repo UNUSED) + struct repository *repo) { int use_internal_rev_list = 0; int all_progress_implied = 0; @@ -5267,6 +5266,10 @@ int cmd_pack_objects(int argc, argc = parse_options(argc, argv, prefix, pack_objects_options, pack_usage, 0); + if (arg_missing_action == MA_ALLOW_ANY || + arg_missing_action == MA_ALLOW_PROMISOR) + fetch_if_missing = 0; + if (argc) { base_name = argv[0]; argc--; @@ -5471,7 +5474,7 @@ int cmd_pack_objects(int argc, progress_state = start_progress(the_repository, _("Enumerating objects"), 0); if (stdin_packs) { - read_stdin_packs(stdin_packs, rev_list_unpacked); + read_stdin_packs(repo, stdin_packs, rev_list_unpacked); } else if (cruft) { read_cruft_objects(); } else if (!use_internal_rev_list) { -- 2.43.0