From d4c7891efc3726246d2ccf48c639547de2d6082f Mon Sep 17 00:00:00 2001 From: Kevin Willford Date: Tue, 24 Jan 2017 17:34:12 +0100 Subject: [PATCH] gvfs: add the core.gvfs config setting This does not do anything yet. The next patches will add various values for that config setting that correspond to the various features offered/required by GVFS. Signed-off-by: Kevin Willford gvfs: refactor loading the core.gvfs config value This code change makes sure that the config value for core_gvfs is always loaded before checking it. Signed-off-by: Kevin Willford --- Documentation/config/core.txt | 3 +++ Makefile | 1 + config.c | 6 +++++ environment.c | 1 + environment.h | 1 + gvfs.c | 44 +++++++++++++++++++++++++++++++++++ gvfs.h | 4 ++++ 7 files changed, 60 insertions(+) create mode 100644 gvfs.c diff --git a/Documentation/config/core.txt b/Documentation/config/core.txt index 5641c4c6eec61a..94e0cb726757b7 100644 --- a/Documentation/config/core.txt +++ b/Documentation/config/core.txt @@ -743,6 +743,9 @@ core.multiPackIndex:: single index. See linkgit:git-multi-pack-index[1] for more information. Defaults to true. +core.gvfs:: + Enable the features needed for GVFS. + core.sparseCheckout:: Enable "sparse checkout" feature. See linkgit:git-sparse-checkout[1] for more information. diff --git a/Makefile b/Makefile index a03d98c8551804..949a2eec0aed1e 100644 --- a/Makefile +++ b/Makefile @@ -1050,6 +1050,7 @@ LIB_OBJS += git-zlib.o LIB_OBJS += gpg-interface.o LIB_OBJS += graph.o LIB_OBJS += grep.o +LIB_OBJS += gvfs.o LIB_OBJS += hash-lookup.o LIB_OBJS += hashmap.o LIB_OBJS += help.o diff --git a/config.c b/config.c index 9523cc858f6e39..136c7754eb2708 100644 --- a/config.c +++ b/config.c @@ -9,6 +9,7 @@ #include "abspath.h" #include "advice.h" #include "date.h" +#include "gvfs.h" #include "branch.h" #include "config.h" #include "parse.h" @@ -1641,6 +1642,11 @@ int git_default_core_config(const char *var, const char *value, return 0; } + if (!strcmp(var, "core.gvfs")) { + gvfs_load_config_value(value); + return 0; + } + if (!strcmp(var, "core.sparsecheckout")) { core_apply_sparse_checkout = git_config_bool(var, value); return 0; diff --git a/environment.c b/environment.c index a73ba9c12caed2..da35d9d7c82b2e 100644 --- a/environment.c +++ b/environment.c @@ -77,6 +77,7 @@ int grafts_keep_true_parents; int core_apply_sparse_checkout; int core_sparse_checkout_cone; int sparse_expect_files_outside_of_patterns; +int core_gvfs; int merge_log_config = -1; int precomposed_unicode = -1; /* see probe_utf8_pathname_composition() */ unsigned long pack_size_limit_cfg; diff --git a/environment.h b/environment.h index 05fd94d7be8749..79005d5a70bc47 100644 --- a/environment.h +++ b/environment.h @@ -146,6 +146,7 @@ int get_shared_repository(void); void reset_shared_repository(void); extern int core_preload_index; +extern int core_gvfs; extern int precomposed_unicode; extern int protect_hfs; extern int protect_ntfs; diff --git a/gvfs.c b/gvfs.c new file mode 100644 index 00000000000000..8aca7261096576 --- /dev/null +++ b/gvfs.c @@ -0,0 +1,44 @@ +#include "git-compat-util.h" +#include "environment.h" +#include "gvfs.h" +#include "setup.h" +#include "config.h" + +static int gvfs_config_loaded; +static int core_gvfs_is_bool; + +static int early_core_gvfs_config(const char *var, const char *value, + const struct config_context *ctx, void *cb) +{ + if (!strcmp(var, "core.gvfs")) + core_gvfs = git_config_bool_or_int("core.gvfs", value, ctx->kvi, + &core_gvfs_is_bool); + return 0; +} + +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); + } else if (startup_info->have_repository == 0) + read_early_config(early_core_gvfs_config, NULL); + else + repo_config_get_bool_or_int(the_repository, "core.gvfs", + &core_gvfs_is_bool, &core_gvfs); + + /* 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); + return (core_gvfs & mask) == mask; +} diff --git a/gvfs.h b/gvfs.h index b6dbe85eae4071..011185dea93734 100644 --- a/gvfs.h +++ b/gvfs.h @@ -1,9 +1,13 @@ #ifndef GVFS_H #define GVFS_H + /* * This file is for the specific settings and methods * used for GVFS functionality */ +void gvfs_load_config_value(const char *value); +int gvfs_config_is_set(int mask); + #endif /* GVFS_H */