Skip to content

Commit

Permalink
gvfs: allow overriding core.gvfs
Browse files Browse the repository at this point in the history
We found a user who had set "core.gvfs = false" in their global
config. This should not have been necessary, but it also should not
have caused a problem. However, it did.

The reason is that gvfs_load_config_value() is called from config.c
when reading config key/value pairs from all the config files. The
local config should override the global config, and this is done by
config.c reading the global config first then reading the local
config. However, our logic only allowed writing the core_gvfs
variable once.

Put the guards against multiple assignments of core_gvfs into
gvfs_config_is_set() instead, because that will fix the problem
_and_ keep multiple calls to gvfs_config_is_set() from slowing down.

Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
  • Loading branch information
derrickstolee authored and dscho committed Sep 18, 2024
1 parent 6a34107 commit fe61f9e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
10 changes: 4 additions & 6 deletions gvfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,6 @@ static int early_core_gvfs_config(const char *var, const char *value,

void gvfs_load_config_value(const char *value)
{
if (gvfs_config_loaded)
return;

if (value) {
struct key_value_info default_kvi = KVI_INIT;
core_gvfs = git_config_bool_or_int("core.gvfs", value, &default_kvi, &core_gvfs_is_bool);
Expand All @@ -34,12 +31,13 @@ void gvfs_load_config_value(const char *value)
/* Turn on all bits if a bool was set in the settings */
if (core_gvfs_is_bool && core_gvfs)
core_gvfs = -1;

gvfs_config_loaded = 1;
}

int gvfs_config_is_set(int mask)
{
gvfs_load_config_value(NULL);
if (!gvfs_config_loaded)
gvfs_load_config_value(NULL);

gvfs_config_loaded = 1;
return (core_gvfs & mask) == mask;
}
4 changes: 4 additions & 0 deletions t/t0021-conversion.sh
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,10 @@ test_expect_success "filter: smudge filters blocked when under GVFS" '
test_config filter.empty-in-repo.smudge "echo smudged && cat" &&
test_config core.gvfs 64 &&
test_must_fail git checkout &&
# ensure the local core.gvfs setting overwrites the global setting
git config --global core.gvfs false &&
test_must_fail git checkout
'

Expand Down

0 comments on commit fe61f9e

Please sign in to comment.