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