]> git.ipfire.org Git - thirdparty/git.git/commit - repository.h
repository: create read_replace_refs setting
authorDerrick Stolee <derrickstolee@github.com>
Tue, 6 Jun 2023 13:24:37 +0000 (13:24 +0000)
committerJunio C Hamano <gitster@pobox.com>
Mon, 12 Jun 2023 20:34:55 +0000 (13:34 -0700)
commit9c7d1b057ff36ee4190621d46e9fe3c83377aea7
tree35f1b6cd905bb444831fabf576ae9ffbc66a69aa
parentf1178380ac645684fcf0519488f9336e55f0946f
repository: create read_replace_refs setting

The 'read_replace_refs' global specifies whether or not we should
respect the references of the form 'refs/replace/<oid>' to replace which
object we look up when asking for '<oid>'. This global has caused issues
when it is not initialized properly, such as in b6551feadfd (merge-tree:
load default git config, 2023-05-10).

To make this more robust, move its config-based initialization out of
git_default_config and into prepare_repo_settings(). This provides a
repository-scoped version of the 'read_replace_refs' global.

The global still has its purpose: it is disabled process-wide by the
GIT_NO_REPLACE_OBJECTS environment variable or by a call to
disable_replace_refs() in some specific Git commands.

Since we already encapsulated the use of the constant inside
replace_refs_enabled(), we can perform the initialization inside that
method, if necessary. This solves the problem of forgetting to check the
config, as we will check it before returning this value.

Due to this encapsulation, the global can move to be static within
replace-object.c.

There is an interesting behavior change possible here: we now have a
repository-scoped understanding of this config value. Thus, if there was
a command that recurses into submodules and might follow replace refs,
then it would now respect the core.useReplaceRefs config value in each
repository.

'git grep --recurse-submodules' is such a command that recurses into
submodules in-process. We can demonstrate the granularity of this config
value via a test in t7814.

Signed-off-by: Derrick Stolee <derrickstolee@github.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
config.c
environment.c
replace-object.c
replace-object.h
repo-settings.c
repository.h
t/t7814-grep-recurse-submodules.sh