зеркало из https://github.com/microsoft/git.git
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 <kewillf@microsoft.com>
This commit is contained in:
Родитель
49e748e582
Коммит
121ba4dbae
1
Makefile
1
Makefile
|
@ -897,6 +897,7 @@ LIB_OBJS += gettext.o
|
|||
LIB_OBJS += gpg-interface.o
|
||||
LIB_OBJS += graph.o
|
||||
LIB_OBJS += grep.o
|
||||
LIB_OBJS += gvfs.o
|
||||
LIB_OBJS += hashmap.o
|
||||
LIB_OBJS += linear-assignment.o
|
||||
LIB_OBJS += help.o
|
||||
|
|
|
@ -0,0 +1,38 @@
|
|||
#include "cache.h"
|
||||
#include "gvfs.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, void *data)
|
||||
{
|
||||
if (!strcmp(var, "core.gvfs"))
|
||||
core_gvfs = git_config_bool_or_int("core.gvfs", value, &core_gvfs_is_bool);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void gvfs_load_config_value(const char *value)
|
||||
{
|
||||
if (gvfs_config_loaded)
|
||||
return;
|
||||
|
||||
if (value)
|
||||
core_gvfs = git_config_bool_or_int("core.gvfs", value, &core_gvfs_is_bool);
|
||||
else if (startup_info->have_repository == 0)
|
||||
read_early_config(early_core_gvfs_config, NULL);
|
||||
else
|
||||
git_config_get_bool_or_int("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(0);
|
||||
return (core_gvfs & mask) == mask;
|
||||
}
|
31
gvfs.h
31
gvfs.h
|
@ -1,8 +1,6 @@
|
|||
#ifndef GVFS_H
|
||||
#define GVFS_H
|
||||
|
||||
#include "cache.h"
|
||||
#include "config.h"
|
||||
|
||||
/*
|
||||
* This file is for the specific settings and methods
|
||||
|
@ -19,32 +17,7 @@
|
|||
#define GVFS_FETCH_SKIP_REACHABILITY_AND_UPLOADPACK (1 << 4)
|
||||
#define GVFS_BLOCK_FILTERS_AND_EOL_CONVERSIONS (1 << 6)
|
||||
|
||||
static inline int gvfs_config_is_set(int mask) {
|
||||
return (core_gvfs & mask) == mask;
|
||||
}
|
||||
|
||||
static inline int gvfs_config_is_set_any(void) {
|
||||
return core_gvfs > 0;
|
||||
}
|
||||
|
||||
static inline void gvfs_load_config_value(const char *value) {
|
||||
int is_bool = 0;
|
||||
|
||||
if (value)
|
||||
core_gvfs = git_config_bool_or_int("core.gvfs", value, &is_bool);
|
||||
else
|
||||
git_config_get_bool_or_int("core.gvfs", &is_bool, &core_gvfs);
|
||||
|
||||
/* Turn on all bits if a bool was set in the settings */
|
||||
if (is_bool && core_gvfs)
|
||||
core_gvfs = -1;
|
||||
}
|
||||
|
||||
|
||||
static inline int gvfs_config_load_and_is_set(int mask) {
|
||||
gvfs_load_config_value(0);
|
||||
return gvfs_config_is_set(mask);
|
||||
}
|
||||
|
||||
void gvfs_load_config_value(const char *value);
|
||||
int gvfs_config_is_set(int mask);
|
||||
|
||||
#endif /* GVFS_H */
|
||||
|
|
Загрузка…
Ссылка в новой задаче