Skip to content

Commit 23a95fb

Browse files
derrickstoleemjcheetham
authored andcommitted
gvfs: allow overriding core.gvfs
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 <[email protected]>
1 parent cea1222 commit 23a95fb

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

gvfs.c

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,6 @@ static int early_core_gvfs_config(const char *var, const char *value,
1919

2020
void gvfs_load_config_value(const char *value)
2121
{
22-
if (gvfs_config_loaded)
23-
return;
24-
2522
if (value) {
2623
struct key_value_info default_kvi = KVI_INIT;
2724
core_gvfs = git_config_bool_or_int("core.gvfs", value, &default_kvi, &core_gvfs_is_bool);
@@ -34,12 +31,13 @@ void gvfs_load_config_value(const char *value)
3431
/* Turn on all bits if a bool was set in the settings */
3532
if (core_gvfs_is_bool && core_gvfs)
3633
core_gvfs = -1;
37-
38-
gvfs_config_loaded = 1;
3934
}
4035

4136
int gvfs_config_is_set(int mask)
4237
{
43-
gvfs_load_config_value(NULL);
38+
if (!gvfs_config_loaded)
39+
gvfs_load_config_value(NULL);
40+
41+
gvfs_config_loaded = 1;
4442
return (core_gvfs & mask) == mask;
4543
}

t/t0021-conversion.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -349,6 +349,10 @@ test_expect_success "filter: smudge filters blocked when under GVFS" '
349349
test_config filter.empty-in-repo.smudge "echo smudged && cat" &&
350350
test_config core.gvfs 64 &&
351351
352+
test_must_fail git checkout &&
353+
354+
# ensure the local core.gvfs setting overwrites the global setting
355+
git config --global core.gvfs false &&
352356
test_must_fail git checkout
353357
'
354358

0 commit comments

Comments
 (0)