Skip to content

environment: consolidate config values#2166

Open
cloobTech wants to merge 3 commits intogit:masterfrom
cloobTech:attr_file_new
Open

environment: consolidate config values#2166
cloobTech wants to merge 3 commits intogit:masterfrom
cloobTech:attr_file_new

Conversation

@cloobTech
Copy link
Contributor

The config values parsed in git_default_config() such as core.attributesFile are loaded eagerly and stored in global variables. Storing these values in global variables can lead to unexpected behaviours when more than one Git repository run in the same Git process.

Move these values into a struct config_values which can be accessed per repository. This centralization will be important in moving other variables and this will prevent us from moving any code from git_default_config(), ensuring the current behaviour remains the same while also enabling the libification of Git.

Suggested-by: Phillip Wood phillip.wood123@gmail.com

Thanks for taking the time to contribute to Git! Please be advised that the
Git community does not use github.com for their contributions. Instead, we use
a mailing list (git@vger.kernel.org) for code submissions, code reviews, and
bug reports. Nevertheless, you can use GitGitGadget (https://gitgitgadget.github.io/)
to conveniently send your Pull Requests commits to our mailing list.

For a single-commit pull request, please leave the pull request description
empty
: your commit message itself should describe your changes.

Please read the "guidelines for contributing" linked above!

@mikecomplexai-7
Copy link

The config values parsed in git_default_config() such as core.attributesFile are loaded eagerly and stored in global variables. Storing these values in global variables can lead to unexpected behaviours when more than one Git repository run in the same Git process.

Move these values into a struct config_values which can be accessed per repository. This centralization will be important in moving other variables and this will prevent us from moving any code from git_default_config(), ensuring the current behaviour remains the same while also enabling the libification of Git.

Suggested-by: Phillip Wood phillip.wood123@gmail.com

Thanks for taking the time to contribute to Git! Please be advised that the Git community does not use github.com for their contributions. Instead, we use a mailing list (git@vger.kernel.org) for code submissions, code reviews, and bug reports. Nevertheless, you can use GitGitGadget (https://gitgitgadget.github.io/) to conveniently send your Pull Requests commits to our mailing list.

For a single-commit pull request, please leave the pull request description empty: your commit message itself should describe your changes.

Please read the "guidelines for contributing" linked above!

@cloobTech cloobTech force-pushed the attr_file_new branch 3 times, most recently from aed3183 to e7f37ba Compare January 24, 2026 12:12
The `core.attributeFile` config value is parsed in
git_default_core_config(), loaded eagerly and stored in the global
variable `git_attributes_file`. Storing this value in a global
variable can lead to it being overwritten by another repository when
more than one Git repository run in the same Git process.

Create a new struct `repo_config_values` to hold this value and
other repository dependent values parsed by `git_default_config()`.
This will ensure the current behaviour remains the same while also
enabling the libification of Git.

An accessor function 'repo_config_values()' is created. It checks
if the address of the passed `repo` instance is the same as
`the_repository` and also if the repository instance has been
initialized before returning the struct.

Suggested-by: Phillip Wood <phillip.wood123@gmail.com>
Mentored-by: Christian Couder <christian.couder@gmail.com>
Mentored-by: Usman Akinyemi <usmanakinyemi202@gmail.com>
Helped-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Olamide Caleb Bello <belkid98@gmail.com>
The config value `core.sparseCheckout` is parsed in
`git_default_core_config()` and stored globally in
`core_apply_sparse_checkout`. This could cause it to be overwritten
by another repository when different Git repositories run in the same
process.

Move the parsed value into `struct repo_config_values` in the_repository
to retain current behaviours and move towards libifying Git.

Suggested-by: Phillip Wood <phillip.wood123@gmail.com>
Mentored-by: Christian Couder <christian.couder@gmail.com>
Mentored-by: Usman Akinyemi <usmanakinyemi202@gmail.com>
Signed-off-by: Olamide Caleb Bello <belkid98@gmail.com>
…lues`

The config value `branch.autoSetupMerge` is parsed in
`git_default_branch_config()` and stored in the global variable
`git_branch_track`. This global variable can be overwritten
by another repository when multiple Git repos run in the the same process.

Move this value into `struct repo_config_values` in the_repository to
retain current behaviours and move towards libifying Git.
Since the variable is no longer a global variable, it has been renamed to
`branch_track` in the struct `repo_config_values`.

Suggested-by: Phillip Wood <phillip.wood123@gmail.com>
Mentored-by: Christian Couder <christian.couder@gmail.com>
Mentored-by: Usman Akinyemi <usmanakinyemi202@gmail.com>
Signed-off-by: Olamide Caleb Bello <belkid98@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants