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

[PATCH v2 8/8] env: move "warn_on_object_refname_ambiguity" into `repo_config_values`

From
Olamide Caleb Bello <belkid98@gmail.com>
Date
Mar 24, 2026, 12:37 UTC
Message-ID
<20260324123750.157143-9-belkid98@gmail.com>
In-Reply-To
<20260324123750.157143-1-belkid98@gmail.com>

The `warn_on_object_refname_ambiguity` variable was previously a global integer, which makes it shared across repository instances in a single process.

Move it into `repo_config_values` so the value is associated with the repository from which it was read. This preserves existing behavior while avoiding cross-repository state leakage and is another step toward eliminating repository-dependent global state.

Update all references to use repo_config_values().
Mentored-by: Christian Couder <christian.couder@gmail.com>
Mentored-by: Usman Akinyemi <usmanakinyemi202@gmail.com>
Signed-off-by: Olamide Caleb Bello <belkid98@gmail.com>
---
 builtin/cat-file.c     | 7 ++++---
 builtin/pack-objects.c | 7 ++++---
 environment.c          | 2 +-
 environment.h          | 2 +-
 object-name.c          | 3 ++-
 revision.c             | 7 ++++---
 submodule.c            | 7 ++++---
 7 files changed, 20 insertions(+), 15 deletions(-)
diff --git a/builtin/cat-file.c b/builtin/cat-file.c
index da059d0e26..32f60f2f64 100644
--- a/builtin/cat-file.c
+++ b/builtin/cat-file.c
@@ -897,6 +897,7 @@ static int batch_objects(struct batch_options *opt)
 	struct strbuf input = STRBUF_INIT;
 	struct strbuf output = STRBUF_INIT;
 	struct expand_data data = EXPAND_DATA_INIT;
+	struct repo_config_values *cfg = repo_config_values(the_repository);
 	int save_warning;
 	int retval = 0;
 
@@ -969,8 +970,8 @@ static int batch_objects(struct batch_options *opt)
 	 * warn) ends up dwarfing the actual cost of the object lookups
 	 * themselves. We can work around it by just turning off the warning.
 	 */
-	save_warning = warn_on_object_refname_ambiguity;
-	warn_on_object_refname_ambiguity = 0;
+	save_warning = cfg->warn_on_object_refname_ambiguity;
+	cfg->warn_on_object_refname_ambiguity = 0;
 
 	if (opt->batch_mode == BATCH_MODE_QUEUE_AND_DISPATCH) {
 		batch_objects_command(opt, &output, &data);
@@ -998,7 +999,7 @@ static int batch_objects(struct batch_options *opt)
  cleanup:
 	strbuf_release(&input);
 	strbuf_release(&output);
-	warn_on_object_refname_ambiguity = save_warning;
+	cfg->warn_on_object_refname_ambiguity = save_warning;
 	return retval;
 }
 
diff --git a/builtin/pack-objects.c b/builtin/pack-objects.c
index 7c5bc96916..b972449ca1 100644
--- a/builtin/pack-objects.c
+++ b/builtin/pack-objects.c
@@ -4653,6 +4653,7 @@ static void get_object_list(struct rev_info *revs, struct strvec *argv)
 	struct setup_revision_opt s_r_opt = {
 		.allow_exclude_promisor_objects = 1,
 	};
+	struct repo_config_values *cfg = repo_config_values(the_repository);
 	char line[1000];
 	int flags = 0;
 	int save_warning;
@@ -4663,8 +4664,8 @@ static void get_object_list(struct rev_info *revs, struct strvec *argv)
 	/* make sure shallows are read */
 	is_repository_shallow(the_repository);
 
-	save_warning = warn_on_object_refname_ambiguity;
-	warn_on_object_refname_ambiguity = 0;
+	save_warning = cfg->warn_on_object_refname_ambiguity;
+	cfg->warn_on_object_refname_ambiguity = 0;
 
 	while (fgets(line, sizeof(line), stdin) != NULL) {
 		int len = strlen(line);
@@ -4692,7 +4693,7 @@ static void get_object_list(struct rev_info *revs, struct strvec *argv)
 			die(_("bad revision '%s'"), line);
 	}
 
-	warn_on_object_refname_ambiguity = save_warning;
+	cfg->warn_on_object_refname_ambiguity = save_warning;
 
 	if (use_bitmap_index && !get_object_list_from_bitmap(revs))
 		return;
diff --git a/environment.c b/environment.c
index 57587ede56..ba2c60103f 100644
--- a/environment.c
+++ b/environment.c
@@ -47,7 +47,6 @@ int minimum_abbrev = 4, default_abbrev = -1;
 int ignore_case;
 int assume_unchanged;
 int is_bare_repository_cfg = -1; /* unspecified */
-int warn_on_object_refname_ambiguity = 1;
 char *git_commit_encoding;
 char *git_log_output_encoding;
 char *apply_default_whitespace;
@@ -725,4 +724,5 @@ void repo_config_values_init(struct repo_config_values *cfg)
 	cfg->precomposed_unicode = -1; /* see probe_utf8_pathname_composition() */
 	cfg->core_sparse_checkout_cone = 0;
 	cfg->sparse_expect_files_outside_of_patterns = 0;
+	cfg->warn_on_object_refname_ambiguity = 1;
 }
diff --git a/environment.h b/environment.h
index 609cdaa07f..1ff0a7ba8b 100644
--- a/environment.h
+++ b/environment.h
@@ -97,6 +97,7 @@ struct repo_config_values {
 	int pack_compression_level;
 	int precomposed_unicode;
 	int core_sparse_checkout_cone;
+	int warn_on_object_refname_ambiguity;
 
 	/* section "sparse" config values */
 	int sparse_expect_files_outside_of_patterns;
@@ -174,7 +175,6 @@ extern int has_symlinks;
 extern int minimum_abbrev, default_abbrev;
 extern int ignore_case;
 extern int assume_unchanged;
-extern int warn_on_object_refname_ambiguity;
 extern char *apply_default_whitespace;
 extern char *apply_default_ignorewhitespace;
 extern unsigned long pack_size_limit_cfg;
diff --git a/object-name.c b/object-name.c
index 7b14c3bf9b..ddd863d293 100644
--- a/object-name.c
+++ b/object-name.c
@@ -969,11 +969,12 @@ static int get_oid_basic(struct repository *r, const char *str, int len,
 	int refs_found = 0;
 	int at, reflog_len, nth_prior = 0;
 	int fatal = !(flags & GET_OID_QUIETLY);
+	struct repo_config_values *cfg = repo_config_values(the_repository);
 
 	if (len == r->hash_algo->hexsz && !get_oid_hex(str, oid)) {
 		if (!(flags & GET_OID_SKIP_AMBIGUITY_CHECK) &&
 		    repo_settings_get_warn_ambiguous_refs(r) &&
-		    warn_on_object_refname_ambiguity) {
+		    cfg->warn_on_object_refname_ambiguity) {
 			refs_found = repo_dwim_ref(r, str, len, &tmp_oid, &real_ref, 0);
 			if (refs_found > 0) {
 				warning(warn_msg, len, str);
diff --git a/revision.c b/revision.c
index 402eb1b029..cff821132b 100644
--- a/revision.c
+++ b/revision.c
@@ -2904,9 +2904,10 @@ static void read_revisions_from_stdin(struct rev_info *revs,
 	int seen_end_of_options = 0;
 	int save_warning;
 	int flags = 0;
+	struct repo_config_values *cfg = repo_config_values(the_repository);
 
-	save_warning = warn_on_object_refname_ambiguity;
-	warn_on_object_refname_ambiguity = 0;
+	save_warning = cfg->warn_on_object_refname_ambiguity;
+	cfg->warn_on_object_refname_ambiguity = 0;
 
 	strbuf_init(&sb, 1000);
 	while (strbuf_getline(&sb, stdin) != EOF) {
@@ -2940,7 +2941,7 @@ static void read_revisions_from_stdin(struct rev_info *revs,
 		read_pathspec_from_stdin(&sb, prune);
 
 	strbuf_release(&sb);
-	warn_on_object_refname_ambiguity = save_warning;
+	cfg->warn_on_object_refname_ambiguity = save_warning;
 }
 
 static void NORETURN diagnose_missing_default(const char *def)
diff --git a/submodule.c b/submodule.c
index 508938e4da..486b41011c 100644
--- a/submodule.c
+++ b/submodule.c
@@ -898,12 +898,13 @@ static void collect_changed_submodules(struct repository *r,
 	struct setup_revision_opt s_r_opt = {
 		.assume_dashdash = 1,
 	};
+	struct repo_config_values *cfg = repo_config_values(the_repository);
 
-	save_warning = warn_on_object_refname_ambiguity;
-	warn_on_object_refname_ambiguity = 0;
+	save_warning = cfg->warn_on_object_refname_ambiguity;
+	cfg->warn_on_object_refname_ambiguity = 0;
 	repo_init_revisions(r, &rev, NULL);
 	setup_revisions_from_strvec(argv, &rev, &s_r_opt);
-	warn_on_object_refname_ambiguity = save_warning;
+	cfg->warn_on_object_refname_ambiguity = save_warning;
 	if (prepare_revision_walk(&rev))
 		die(_("revision walk setup failed"));
 
-- 
2.53.0.155.g9f36b15afa
Previous: Olamide Caleb BelloNext: Karthik Nayak
Message 19 of 72 in “repo_config_values: migrate more globals”
  1. 0/8 repo_config_values: migrate more globalsOlamide Caleb Bello, Mar 24, 2026
  2. 1/8 environment: move "trust_ctime" into `struct repo_config_values`Olamide Caleb Bello, Mar 24, 2026
  3. Karthik NayakApr 14, 2026
  4. Phillip WoodApr 14, 2026
  5. Junio C HamanoApr 14, 2026
  6. Karthik NayakApr 15, 2026
  7. Junio C HamanoApr 15, 2026
  8. Karthik NayakApr 15, 2026
  9. 2/8 environment: move "check_stat" into `struct repo_config_values`Olamide Caleb Bello, Mar 24, 2026
  10. Karthik NayakApr 14, 2026
  11. 3/8 environment: move `zlib_compression_level` into repo_config_valuesOlamide Caleb Bello, Mar 24, 2026
  12. Karthik NayakApr 14, 2026
  13. Bello OlamideApr 14, 2026
  14. 4/8 environment: move "pack_compression_level" into `struct repo_config_values`Olamide Caleb Bello, Mar 24, 2026
  15. 5/8 environment: move "precomposed_unicode" into `struct repo_config_values`Olamide Caleb Bello, Mar 24, 2026
  16. Karthik NayakApr 14, 2026
  17. 6/8 env: move "core_sparse_checkout_cone" into `struct repo_config_values`Olamide Caleb Bello, Mar 24, 2026
  18. 7/8 env: put "sparse_expect_files_outside_of_patterns" in `repo_config_values`Olamide Caleb Bello, Mar 24, 2026
  19. 8/8 env: move "warn_on_object_refname_ambiguity" into `repo_config_values`Olamide Caleb Bello, Mar 24, 2026
  20. Karthik NayakApr 14, 2026
  21. Bello OlamideApr 14, 2026
  22. 0/8 repo_config_values: migrate more globalsOlamide Caleb Bello, Apr 23, 2026
  23. 1/8 Revert "compat/posix: introduce writev(3p) wrapper"Olamide Caleb Bello, Apr 23, 2026
  24. 2/8 rust: we are way beyond 2.53Olamide Caleb Bello, Apr 23, 2026
  25. 3/8 doc: am: revert Message-ID trailer claimOlamide Caleb Bello, Apr 23, 2026
  26. 4/8 doc: am: correct to full --no-message-idOlamide Caleb Bello, Apr 23, 2026
  27. 5/8 CI: bump actions/checkout from 4 to 5 for rust-analysis jobOlamide Caleb Bello, Apr 23, 2026
  28. 6/8 gitglossary: fix indentation of sub-listsOlamide Caleb Bello, Apr 23, 2026
  29. 7/8 Hopefully the final tweak before -rc2Olamide Caleb Bello, Apr 23, 2026
  30. 8/8 Git 2.54-rc2Olamide Caleb Bello, Apr 23, 2026
  31. Bello OlamideApr 23, 2026
  32. 0/8 repo_config_values: migrate more globalsOlamide Caleb Bello, Jun 1, 2026
  33. 1/8 environment: move "trust_ctime" into `struct repo_config_values`Olamide Caleb Bello, Jun 1, 2026
  34. 2/8 environment: move "check_stat" into `struct repo_config_values`Olamide Caleb Bello, Jun 1, 2026
  35. 3/8 environment: move `zlib_compression_level` into `struct repo_config_values`Olamide Caleb Bello, Jun 1, 2026
  36. Junio C HamanoJun 2, 2026
  37. Patrick SteinhardtJun 2, 2026
  38. Christian CouderJun 2, 2026
  39. Junio C HamanoJun 2, 2026
  40. 4/8 environment: move "pack_compression_level" into `struct repo_config_values`Olamide Caleb Bello, Jun 1, 2026
  41. 5/8 environment: move "precomposed_unicode" into `struct repo_config_values`Olamide Caleb Bello, Jun 1, 2026
  42. Junio C HamanoJun 1, 2026
  43. 6/8 environment: move "core_sparse_checkout_cone" into `struct repo_config_values`Olamide Caleb Bello, Jun 1, 2026
  44. 7/8 environment: move "sparse_expect_files_outside_of_patterns" into `repo_config_values`Olamide Caleb Bello, Jun 1, 2026
  45. 8/8 environment: move "warn_on_object_refname_ambiguity" into `struct repo_config_values`Olamide Caleb Bello, Jun 1, 2026
  46. Junio C HamanoJun 2, 2026
  47. 0/8 repo_config_values: migrate more globals variablesOlamide Caleb Bello, Jun 2, 2026
  48. 1/8 environment: move "trust_ctime" into `struct repo_config_values`Olamide Caleb Bello, Jun 2, 2026
  49. 2/8 environment: move "check_stat" into `struct repo_config_values`Olamide Caleb Bello, Jun 2, 2026
  50. 3/8 environment: move `zlib_compression_level` into `struct repo_config_values`Olamide Caleb Bello, Jun 2, 2026
  51. 4/8 environment: move "pack_compression_level" into `struct repo_config_values`Olamide Caleb Bello, Jun 2, 2026
  52. 5/8 environment: move "precomposed_unicode" into `struct repo_config_values`Olamide Caleb Bello, Jun 2, 2026
  53. 6/8 environment: move "core_sparse_checkout_cone" into `struct repo_config_values`Olamide Caleb Bello, Jun 2, 2026
  54. 7/8 environment: move "sparse_expect_files_outside_of_patterns" into `struct repo_config_values`Olamide Caleb Bello, Jun 2, 2026
  55. 8/8 environment: move "warn_on_object_refname_ambiguity" into `struct repo_config_values`Olamide Caleb Bello, Jun 2, 2026
  56. 0/8 environment: move core config globals into repo_config_valuesOlamide Caleb Bello, Apr 23, 2026
  57. 1/8 environment: move "trust_ctime" into `struct repo_config_values`Olamide Caleb Bello, Apr 23, 2026
  58. Tian YuchenMay 21, 2026
  59. Bello OlamideJun 1, 2026
  60. 2/8 environment: move "check_stat" into `struct repo_config_values`Olamide Caleb Bello, Apr 23, 2026
  61. 3/8 environment: move `zlib_compression_level` into `struct repo_config_values`Olamide Caleb Bello, Apr 23, 2026
  62. 4/8 environment: move "pack_compression_level" into `struct repo_config_values`Olamide Caleb Bello, Apr 23, 2026
  63. 5/8 environment: move "precomposed_unicode" into `struct repo_config_values`Olamide Caleb Bello, Apr 23, 2026
  64. Tian YuchenMay 15, 2026
  65. 6/8 env: move "core_sparse_checkout_cone" into `struct repo_config_values`Olamide Caleb Bello, Apr 23, 2026
  66. 7/8 env: move "sparse_expect_files_outside_of_patterns" into `repo_config_values`Olamide Caleb Bello, Apr 23, 2026
  67. 8/8 env: move "warn_on_object_refname_ambiguity" into `struct repo_config_values`Olamide Caleb Bello, Apr 23, 2026
  68. Junio C HamanoApr 26, 2026
  69. Bello OlamideApr 26, 2026
  70. Junio C HamanoMay 11, 2026
  71. Junio C HamanoJun 1, 2026
  72. Junio C HamanoJun 1, 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.