Subject: Re: [Outreachy PATCH v6 1/3] environment: stop storing `core.attributesFile` globally

From: Bello Caleb Olamide <[email-masked]>
Date: Tue, 10 Feb 2026 11:17:21 +0100

This is how I implemented the suggestion

diff --git a/oss-fuzz/fuzz-commit-graph.c b/oss-fuzz/fuzz-commit-graph.c
index fb8b8787a4..59bbb849d1 100644
--- a/oss-fuzz/fuzz-commit-graph.c
+++ b/oss-fuzz/fuzz-commit-graph.c
@@ -10,6 +10,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
 {
 	struct commit_graph *g;
 
+	memset(the_repository, 0, sizeof(*the_repository));
 	initialize_repository(the_repository);
 
 	/*
diff --git a/repository.c b/repository.c
index c7e75215ac..0af40b016e 100644
--- a/repository.c
+++ b/repository.c
@@ -50,13 +50,27 @@ static void set_default_hash_algo(struct repository *repo)
 	repo_set_hash_algo(repo, algo);
 }
 
+struct repo_config_values *repo_config_values(struct repository *repo)
+{
+	if (repo != the_repository)
+		BUG("trying to read config from wrong repository instance");
+	if(!repo->initialized)
+		BUG("config values from uninitialized repository");
+	return &repo->config_values_private_;
+}
+
 void initialize_repository(struct repository *repo)
 {
+	if (repo->initialized)
+		BUG("repository initialized already");
+	repo->initialized = true;
+
 	repo->remote_state = remote_state_new();
 	repo->parsed_objects = parsed_object_pool_new(repo);
 	ALLOC_ARRAY(repo->index, 1);
 	index_state_init(repo->index, repo);
 	repo->check_deprecated_config = true;
+	repo_config_values_init(repo_config_values(repo));
 
 	/*
 	 * When a command runs inside a repository, it learns what

Some of the tests that fail are related to the submodule and a
couple output is shown below

./t7412-submodule-absorbgitdirs.sh  -i -v
...
Initialized empty Git repository in /home/ubuntu/Code/open_source/git/t/trash directory.t7412-submodule-absorbgitdirs/sub1/.git/
[master (root-commit) 50e526b] first
 Author: A U Thor <[email-masked]>
 1 file changed, 1 insertion(+)
 create mode 100644 first.t
BUG: repository.c:56: trying to read config from wrong repository instance
Aborted (core dumped)
not ok 1 - setup a real submodule
#
# cwd="$(pwd)" &&
# git init sub1 &&
# test_commit -C sub1 first &&
# git submodule add ./sub1 &&
# test_tick &&
# git commit -m superproject
#
1..1

./t4027-diff-submodule.sh  -i -v
...
Initialized empty Git repository in /home/ubuntu/Code/open_source/git/t/trash directory.t4027-diff-submodule/sub/.git/
[master (root-commit) 4431e0b] submodule
 Author: A U Thor <[email-masked]>
 1 file changed, 1 insertion(+)
 create mode 100644 world
BUG: repository.c:56: trying to read config from wrong repository instance
Aborted (core dumped)
not ok 1 - setup
#
# test_tick &&
# test_create_repo sub &&
# (
# cd sub &&
# echo hello >world &&
# git add world &&
# git commit -m submodule
# ) &&
#
# test_tick &&
# echo frotz >nitfol &&
# git add nitfol sub &&
# git commit -m superproject &&
#
# (
# cd sub &&
# echo goodbye >world &&
# git add world &&
# git commit -m "submodule #2"
# ) &&
#
# git -C sub rev-list HEAD >revs &&
# set x $(cat revs) &&
# echo ":160000 160000 $3 $ZERO_OID M sub" >expect &&
# subtip=$3 subprev=$2
#
1..1

Thanks