|
| 1 | +#include "git-compat-util.h" |
| 2 | +#include "environment.h" |
| 3 | +#include "gvfs.h" |
| 4 | +#include "setup.h" |
| 5 | +#include "config.h" |
| 6 | + |
| 7 | +static int gvfs_config_loaded; |
| 8 | +static int core_gvfs_is_bool; |
| 9 | + |
| 10 | +static int early_core_gvfs_config(const char *var, const char *value, |
| 11 | + const struct config_context *ctx, void *cb) |
| 12 | +{ |
| 13 | + if (!strcmp(var, "core.gvfs")) |
| 14 | + core_gvfs = git_config_bool_or_int("core.gvfs", value, ctx->kvi, |
| 15 | + &core_gvfs_is_bool); |
| 16 | + return 0; |
| 17 | +} |
| 18 | + |
| 19 | +void gvfs_load_config_value(const char *value) |
| 20 | +{ |
| 21 | + if (gvfs_config_loaded) |
| 22 | + return; |
| 23 | + |
| 24 | + if (value) { |
| 25 | + struct key_value_info default_kvi = KVI_INIT; |
| 26 | + core_gvfs = git_config_bool_or_int("core.gvfs", value, &default_kvi, &core_gvfs_is_bool); |
| 27 | + } else if (startup_info->have_repository == 0) |
| 28 | + read_early_config(early_core_gvfs_config, NULL); |
| 29 | + else |
| 30 | + repo_config_get_bool_or_int(the_repository, "core.gvfs", |
| 31 | + &core_gvfs_is_bool, &core_gvfs); |
| 32 | + |
| 33 | + /* Turn on all bits if a bool was set in the settings */ |
| 34 | + if (core_gvfs_is_bool && core_gvfs) |
| 35 | + core_gvfs = -1; |
| 36 | + |
| 37 | + gvfs_config_loaded = 1; |
| 38 | +} |
| 39 | + |
| 40 | +int gvfs_config_is_set(int mask) |
| 41 | +{ |
| 42 | + gvfs_load_config_value(NULL); |
| 43 | + return (core_gvfs & mask) == mask; |
| 44 | +} |
0 commit comments