Skip to content

Encoding with repo config#2231

Open
malon7782 wants to merge 6 commits intogit:masterfrom
malon7782:encoding-with-repo-config
Open

Encoding with repo config#2231
malon7782 wants to merge 6 commits intogit:masterfrom
malon7782:encoding-with-repo-config

Conversation

@malon7782
Copy link
Contributor

No description provided.

cloobTech and others added 6 commits March 2, 2026 15:57
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()' s created to ensure
that we do not access an uninitialized repository, or an instance
of a different repository than the current one.

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>
To pave the way for reducing the global state tied to commit encoding
in a subsequent patch, functions like 'commit_tree()' and
'commit_tree_extended()' must be able to access a repository instance.

Plumb the 'struct repository' pointer down the call chain for these
APIs. For built-ins or subsystems already dependent on global state
(e.g., 'notes_cache_write()'), fallback to 'the_repository'.

No functional changes are introduced in this preparatory step.

Signed-off-by: Tian Yuchen <a3205153416@gmail.com>
To prepare for the elimination of the global state associated with
'log_output_encoding', functions responsible for formatting commit
messages, such as 'pretty_print_commit()' and 'pp_commit_easy()',
must be able to access a repository instance.

Plumb the 'struct repository' pointer down the call chain for these
APIs. Where no such context is readily available in built-ins or
high-level functions, fallback to 'the_repository'.

Signed-off-by: Tian Yuchen <a3205153416@gmail.com>
The global variables 'git_commit_encoding' and 'git_log_output_encoding'
prevent libification.

Migrate these variables into the 'struct repo_config_values'. This ensures
that they are safely accessed via the 'repo_config_values()' accessor which
prevents uninitialized or cross-repository access.

Note that these variables are not migrated to 'repo_settings'. As eagerly
parsed user preferences, deferring them to lazy evaluation would break
early validation.

Currently, during the config parsing phase in 'git_default_i18n_config()',
the values are still parsed into the 'the_repository' instance of
'repo_config_values', Since safely plumbing a repository pointer through
the 'git_default_config' callback machinery remains highly invasive due
to custom contexts being passed via the 'void *cb' parameter.
However, the read-paths (commit APIs and log formatters) updated in
previous patches are now fully plumbed to accept any repository
instance.

Signed-off-by: Tian Yuchen <a3205153416@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