git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH v5 1/2] pack-objects: give fetch_if_missing call sites access to 'repo'

From
Tian Yuchen <cat@malon.dev>
Date
Aug 14, 2026, 07:24 UTC
Message-ID
<20260814072419.1666358-2-cat@malon.dev>
In-Reply-To
<20260814072419.1666358-1-cat@malon.dev>

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 <christian.couder@gmail.com>
Mentored-by: Ayush Chandekar <ayu.chandekar@gmail.com>
Mentored-by: Olamide Caleb Bello <belkid98@gmail.com>
Signed-off-by: Tian Yuchen <cat@malon.dev>
---
 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
Previous: Tian YuchenNext: Junio C Hamano
Message 19 of 26 in “repository: move fetch_if_missing into struct repository”
  1. repository: move fetch_if_missing into struct repositoryTian Yuchen, Jul 15, 2026
  2. Junio C HamanoJul 15, 2026
  3. Tian YuchenJul 15, 2026
  4. Patrick SteinhardtJul 15, 2026
  5. Tian YuchenJul 16, 2026
  6. Junio C HamanoJul 16, 2026
  7. repository: move fetch_if_missing into struct repositoryTian Yuchen, Jul 16, 2026
  8. Tian YuchenAug 1, 2026
  9. Patrick SteinhardtAug 4, 2026
  10. Junio C HamanoAug 4, 2026
  11. Tian YuchenAug 5, 2026
  12. Tian YuchenAug 5, 2026
  13. repository: move fetch_if_missing into struct repositoryTian Yuchen, Aug 7, 2026
  14. Junio C HamanoAug 7, 2026
  15. Tian YuchenAug 9, 2026
  16. repository: move fetch_if_missing into struct repositoryTian Yuchen, Aug 13, 2026
  17. Junio C HamanoAug 13, 2026
  18. 0/2 repository: move fetch_if_missing into struct repositoryTian Yuchen, Aug 14, 2026
  19. 1/2 pack-objects: give fetch_if_missing call sites access to 'repo'Tian Yuchen, Aug 14, 2026
  20. Junio C HamanoAug 14, 2026
  21. Tian YuchenAug 15, 2026
  22. 2/2 repository: move fetch_if_missing into struct repositoryTian Yuchen, Aug 14, 2026
  23. Junio C HamanoAug 14, 2026
  24. repository: move fetch_if_missing into struct repositoryTian Yuchen, Aug 15, 2026
  25. Junio C HamanoAug 15, 2026
  26. Tian YuchenAug 16, 2026

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.