Commit 658022c4 by Patrick Steinhardt

configuration: cvar -> configmap

`cvar` is an unhelpful name.  Refactor its usage to `configmap` for more
clarity.
parent 343fb83a
...@@ -92,20 +92,20 @@ typedef struct git_config_iterator git_config_iterator; ...@@ -92,20 +92,20 @@ typedef struct git_config_iterator git_config_iterator;
* Config var type * Config var type
*/ */
typedef enum { typedef enum {
GIT_CVAR_FALSE = 0, GIT_CONFIGMAP_FALSE = 0,
GIT_CVAR_TRUE = 1, GIT_CONFIGMAP_TRUE = 1,
GIT_CVAR_INT32, GIT_CONFIGMAP_INT32,
GIT_CVAR_STRING GIT_CONFIGMAP_STRING
} git_cvar_t; } git_configmap_t;
/** /**
* Mapping from config variables to values. * Mapping from config variables to values.
*/ */
typedef struct { typedef struct {
git_cvar_t cvar_type; git_configmap_t type;
const char *str_match; const char *str_match;
int map_value; int map_value;
} git_cvar_map; } git_configmap;
/** /**
* Locate the path to the global configuration file * Locate the path to the global configuration file
...@@ -623,7 +623,7 @@ GIT_EXTERN(int) git_config_foreach_match( ...@@ -623,7 +623,7 @@ GIT_EXTERN(int) git_config_foreach_match(
* *
* A mapping array looks as follows: * A mapping array looks as follows:
* *
* git_cvar_map autocrlf_mapping[] = { * git_configmap autocrlf_mapping[] = {
* {GIT_CVAR_FALSE, NULL, GIT_AUTO_CRLF_FALSE}, * {GIT_CVAR_FALSE, NULL, GIT_AUTO_CRLF_FALSE},
* {GIT_CVAR_TRUE, NULL, GIT_AUTO_CRLF_TRUE}, * {GIT_CVAR_TRUE, NULL, GIT_AUTO_CRLF_TRUE},
* {GIT_CVAR_STRING, "input", GIT_AUTO_CRLF_INPUT}, * {GIT_CVAR_STRING, "input", GIT_AUTO_CRLF_INPUT},
...@@ -644,7 +644,7 @@ GIT_EXTERN(int) git_config_foreach_match( ...@@ -644,7 +644,7 @@ GIT_EXTERN(int) git_config_foreach_match(
* @param out place to store the result of the mapping * @param out place to store the result of the mapping
* @param cfg config file to get the variables from * @param cfg config file to get the variables from
* @param name name of the config variable to lookup * @param name name of the config variable to lookup
* @param maps array of `git_cvar_map` objects specifying the possible mappings * @param maps array of `git_configmap` objects specifying the possible mappings
* @param map_n number of mapping objects in `maps` * @param map_n number of mapping objects in `maps`
* @return 0 on success, error code otherwise * @return 0 on success, error code otherwise
*/ */
...@@ -652,20 +652,20 @@ GIT_EXTERN(int) git_config_get_mapped( ...@@ -652,20 +652,20 @@ GIT_EXTERN(int) git_config_get_mapped(
int *out, int *out,
const git_config *cfg, const git_config *cfg,
const char *name, const char *name,
const git_cvar_map *maps, const git_configmap *maps,
size_t map_n); size_t map_n);
/** /**
* Maps a string value to an integer constant * Maps a string value to an integer constant
* *
* @param out place to store the result of the parsing * @param out place to store the result of the parsing
* @param maps array of `git_cvar_map` objects specifying the possible mappings * @param maps array of `git_configmap` objects specifying the possible mappings
* @param map_n number of mapping objects in `maps` * @param map_n number of mapping objects in `maps`
* @param value value to parse * @param value value to parse
*/ */
GIT_EXTERN(int) git_config_lookup_map_value( GIT_EXTERN(int) git_config_lookup_map_value(
int *out, int *out,
const git_cvar_map *maps, const git_configmap *maps,
size_t map_n, size_t map_n,
const char *value); const char *value);
......
...@@ -1391,7 +1391,7 @@ static bool should_remove_existing(checkout_data *data) ...@@ -1391,7 +1391,7 @@ static bool should_remove_existing(checkout_data *data)
{ {
int ignorecase; int ignorecase;
if (git_repository__cvar(&ignorecase, data->repo, GIT_CVAR_IGNORECASE) < 0) { if (git_repository__configmap_lookup(&ignorecase, data->repo, GIT_CONFIGMAP_IGNORECASE) < 0) {
ignorecase = 0; ignorecase = 0;
} }
...@@ -2463,12 +2463,12 @@ static int checkout_data_init( ...@@ -2463,12 +2463,12 @@ static int checkout_data_init(
data->pfx = git_pathspec_prefix(&data->opts.paths); data->pfx = git_pathspec_prefix(&data->opts.paths);
if ((error = git_repository__cvar( if ((error = git_repository__configmap_lookup(
&data->can_symlink, repo, GIT_CVAR_SYMLINKS)) < 0) &data->can_symlink, repo, GIT_CONFIGMAP_SYMLINKS)) < 0)
goto cleanup; goto cleanup;
if ((error = git_repository__cvar( if ((error = git_repository__configmap_lookup(
&data->respect_filemode, repo, GIT_CVAR_FILEMODE)) < 0) &data->respect_filemode, repo, GIT_CONFIGMAP_FILEMODE)) < 0)
goto cleanup; goto cleanup;
if (!data->opts.baseline && !data->opts.baseline_index) { if (!data->opts.baseline && !data->opts.baseline_index) {
......
...@@ -661,7 +661,7 @@ int git_config_set_string(git_config *cfg, const char *name, const char *value) ...@@ -661,7 +661,7 @@ int git_config_set_string(git_config *cfg, const char *name, const char *value)
error = backend->set(backend, name, value); error = backend->set(backend, name, value);
if (!error && GIT_REFCOUNT_OWNER(cfg) != NULL) if (!error && GIT_REFCOUNT_OWNER(cfg) != NULL)
git_repository__cvar_cache_clear(GIT_REFCOUNT_OWNER(cfg)); git_repository__configmap_lookup_cache_clear(GIT_REFCOUNT_OWNER(cfg));
return error; return error;
} }
...@@ -777,7 +777,7 @@ int git_config_get_mapped( ...@@ -777,7 +777,7 @@ int git_config_get_mapped(
int *out, int *out,
const git_config *cfg, const git_config *cfg,
const char *name, const char *name,
const git_cvar_map *maps, const git_configmap *maps,
size_t map_n) size_t map_n)
{ {
git_config_entry *entry; git_config_entry *entry;
...@@ -1223,7 +1223,7 @@ int git_config_unlock(git_config *cfg, int commit) ...@@ -1223,7 +1223,7 @@ int git_config_unlock(git_config *cfg, int commit)
int git_config_lookup_map_value( int git_config_lookup_map_value(
int *out, int *out,
const git_cvar_map *maps, const git_configmap *maps,
size_t map_n, size_t map_n,
const char *value) const char *value)
{ {
...@@ -1233,27 +1233,27 @@ int git_config_lookup_map_value( ...@@ -1233,27 +1233,27 @@ int git_config_lookup_map_value(
goto fail_parse; goto fail_parse;
for (i = 0; i < map_n; ++i) { for (i = 0; i < map_n; ++i) {
const git_cvar_map *m = maps + i; const git_configmap *m = maps + i;
switch (m->cvar_type) { switch (m->type) {
case GIT_CVAR_FALSE: case GIT_CONFIGMAP_FALSE:
case GIT_CVAR_TRUE: { case GIT_CONFIGMAP_TRUE: {
int bool_val; int bool_val;
if (git__parse_bool(&bool_val, value) == 0 && if (git__parse_bool(&bool_val, value) == 0 &&
bool_val == (int)m->cvar_type) { bool_val == (int)m->type) {
*out = m->map_value; *out = m->map_value;
return 0; return 0;
} }
break; break;
} }
case GIT_CVAR_INT32: case GIT_CONFIGMAP_INT32:
if (git_config_parse_int32(out, value) == 0) if (git_config_parse_int32(out, value) == 0)
return 0; return 0;
break; break;
case GIT_CVAR_STRING: case GIT_CONFIGMAP_STRING:
if (strcasecmp(value, m->str_match) == 0) { if (strcasecmp(value, m->str_match) == 0) {
*out = m->map_value; *out = m->map_value;
return 0; return 0;
...@@ -1267,18 +1267,18 @@ fail_parse: ...@@ -1267,18 +1267,18 @@ fail_parse:
return -1; return -1;
} }
int git_config_lookup_map_enum(git_cvar_t *type_out, const char **str_out, int git_config_lookup_map_enum(git_configmap_t *type_out, const char **str_out,
const git_cvar_map *maps, size_t map_n, int enum_val) const git_configmap *maps, size_t map_n, int enum_val)
{ {
size_t i; size_t i;
for (i = 0; i < map_n; i++) { for (i = 0; i < map_n; i++) {
const git_cvar_map *m = &maps[i]; const git_configmap *m = &maps[i];
if (m->map_value != enum_val) if (m->map_value != enum_val)
continue; continue;
*type_out = m->cvar_type; *type_out = m->type;
*str_out = m->str_match; *str_out = m->str_match;
return 0; return 0;
} }
......
...@@ -66,18 +66,19 @@ extern int git_config__get_bool_force( ...@@ -66,18 +66,19 @@ extern int git_config__get_bool_force(
extern int git_config__get_int_force( extern int git_config__get_int_force(
const git_config *cfg, const char *key, int fallback_value); const git_config *cfg, const char *key, int fallback_value);
/* API for repository cvar-style lookups from config - not cached, but /* API for repository configmap-style lookups from config - not cached, but
* uses cvar value maps and fallbacks * uses configmap value maps and fallbacks
*/ */
extern int git_config__cvar( extern int git_config__configmap_lookup(
int *out, git_config *config, git_cvar_cached cvar); int *out, git_config *config, git_configmap_item item);
/** /**
* The opposite of git_config_lookup_map_value, we take an enum value * The opposite of git_config_lookup_map_value, we take an enum value
* and map it to the string or bool value on the config. * and map it to the string or bool value on the config.
*/ */
int git_config_lookup_map_enum(git_cvar_t *type_out, const char **str_out, int git_config_lookup_map_enum(git_configmap_t *type_out,
const git_cvar_map *maps, size_t map_n, int enum_val); const char **str_out, const git_configmap *maps,
size_t map_n, int enum_val);
/** /**
* Unlock the backend with the highest priority * Unlock the backend with the highest priority
......
...@@ -15,8 +15,8 @@ ...@@ -15,8 +15,8 @@
#include "filter.h" #include "filter.h"
struct map_data { struct map_data {
const char *cvar_name; const char *name;
git_cvar_map *maps; git_configmap *maps;
size_t map_count; size_t map_count;
int default_value; int default_value;
}; };
...@@ -29,11 +29,11 @@ struct map_data { ...@@ -29,11 +29,11 @@ struct map_data {
* value is native. See gitattributes(5) for more information on * value is native. See gitattributes(5) for more information on
* end-of-line conversion. * end-of-line conversion.
*/ */
static git_cvar_map _cvar_map_eol[] = { static git_configmap _configmap_eol[] = {
{GIT_CVAR_FALSE, NULL, GIT_EOL_UNSET}, {GIT_CONFIGMAP_FALSE, NULL, GIT_EOL_UNSET},
{GIT_CVAR_STRING, "lf", GIT_EOL_LF}, {GIT_CONFIGMAP_STRING, "lf", GIT_EOL_LF},
{GIT_CVAR_STRING, "crlf", GIT_EOL_CRLF}, {GIT_CONFIGMAP_STRING, "crlf", GIT_EOL_CRLF},
{GIT_CVAR_STRING, "native", GIT_EOL_NATIVE} {GIT_CONFIGMAP_STRING, "native", GIT_EOL_NATIVE}
}; };
/* /*
...@@ -46,55 +46,55 @@ static git_cvar_map _cvar_map_eol[] = { ...@@ -46,55 +46,55 @@ static git_cvar_map _cvar_map_eol[] = {
* does not have normalized line endings. This variable can be set to input, * does not have normalized line endings. This variable can be set to input,
* in which case no output conversion is performed. * in which case no output conversion is performed.
*/ */
static git_cvar_map _cvar_map_autocrlf[] = { static git_configmap _configmap_autocrlf[] = {
{GIT_CVAR_FALSE, NULL, GIT_AUTO_CRLF_FALSE}, {GIT_CONFIGMAP_FALSE, NULL, GIT_AUTO_CRLF_FALSE},
{GIT_CVAR_TRUE, NULL, GIT_AUTO_CRLF_TRUE}, {GIT_CONFIGMAP_TRUE, NULL, GIT_AUTO_CRLF_TRUE},
{GIT_CVAR_STRING, "input", GIT_AUTO_CRLF_INPUT} {GIT_CONFIGMAP_STRING, "input", GIT_AUTO_CRLF_INPUT}
}; };
static git_cvar_map _cvar_map_safecrlf[] = { static git_configmap _configmap_safecrlf[] = {
{GIT_CVAR_FALSE, NULL, GIT_SAFE_CRLF_FALSE}, {GIT_CONFIGMAP_FALSE, NULL, GIT_SAFE_CRLF_FALSE},
{GIT_CVAR_TRUE, NULL, GIT_SAFE_CRLF_FAIL}, {GIT_CONFIGMAP_TRUE, NULL, GIT_SAFE_CRLF_FAIL},
{GIT_CVAR_STRING, "warn", GIT_SAFE_CRLF_WARN} {GIT_CONFIGMAP_STRING, "warn", GIT_SAFE_CRLF_WARN}
}; };
static git_cvar_map _cvar_map_logallrefupdates[] = { static git_configmap _configmap_logallrefupdates[] = {
{GIT_CVAR_FALSE, NULL, GIT_LOGALLREFUPDATES_FALSE}, {GIT_CONFIGMAP_FALSE, NULL, GIT_LOGALLREFUPDATES_FALSE},
{GIT_CVAR_TRUE, NULL, GIT_LOGALLREFUPDATES_TRUE}, {GIT_CONFIGMAP_TRUE, NULL, GIT_LOGALLREFUPDATES_TRUE},
{GIT_CVAR_STRING, "always", GIT_LOGALLREFUPDATES_ALWAYS}, {GIT_CONFIGMAP_STRING, "always", GIT_LOGALLREFUPDATES_ALWAYS},
}; };
/* /*
* Generic map for integer values * Generic map for integer values
*/ */
static git_cvar_map _cvar_map_int[] = { static git_configmap _configmap_int[] = {
{GIT_CVAR_INT32, NULL, 0}, {GIT_CONFIGMAP_INT32, NULL, 0},
}; };
static struct map_data _cvar_maps[] = { static struct map_data _configmaps[] = {
{"core.autocrlf", _cvar_map_autocrlf, ARRAY_SIZE(_cvar_map_autocrlf), GIT_AUTO_CRLF_DEFAULT}, {"core.autocrlf", _configmap_autocrlf, ARRAY_SIZE(_configmap_autocrlf), GIT_AUTO_CRLF_DEFAULT},
{"core.eol", _cvar_map_eol, ARRAY_SIZE(_cvar_map_eol), GIT_EOL_DEFAULT}, {"core.eol", _configmap_eol, ARRAY_SIZE(_configmap_eol), GIT_EOL_DEFAULT},
{"core.symlinks", NULL, 0, GIT_SYMLINKS_DEFAULT }, {"core.symlinks", NULL, 0, GIT_SYMLINKS_DEFAULT },
{"core.ignorecase", NULL, 0, GIT_IGNORECASE_DEFAULT }, {"core.ignorecase", NULL, 0, GIT_IGNORECASE_DEFAULT },
{"core.filemode", NULL, 0, GIT_FILEMODE_DEFAULT }, {"core.filemode", NULL, 0, GIT_FILEMODE_DEFAULT },
{"core.ignorestat", NULL, 0, GIT_IGNORESTAT_DEFAULT }, {"core.ignorestat", NULL, 0, GIT_IGNORESTAT_DEFAULT },
{"core.trustctime", NULL, 0, GIT_TRUSTCTIME_DEFAULT }, {"core.trustctime", NULL, 0, GIT_TRUSTCTIME_DEFAULT },
{"core.abbrev", _cvar_map_int, 1, GIT_ABBREV_DEFAULT }, {"core.abbrev", _configmap_int, 1, GIT_ABBREV_DEFAULT },
{"core.precomposeunicode", NULL, 0, GIT_PRECOMPOSE_DEFAULT }, {"core.precomposeunicode", NULL, 0, GIT_PRECOMPOSE_DEFAULT },
{"core.safecrlf", _cvar_map_safecrlf, ARRAY_SIZE(_cvar_map_safecrlf), GIT_SAFE_CRLF_DEFAULT}, {"core.safecrlf", _configmap_safecrlf, ARRAY_SIZE(_configmap_safecrlf), GIT_SAFE_CRLF_DEFAULT},
{"core.logallrefupdates", _cvar_map_logallrefupdates, ARRAY_SIZE(_cvar_map_logallrefupdates), GIT_LOGALLREFUPDATES_DEFAULT}, {"core.logallrefupdates", _configmap_logallrefupdates, ARRAY_SIZE(_configmap_logallrefupdates), GIT_LOGALLREFUPDATES_DEFAULT},
{"core.protecthfs", NULL, 0, GIT_PROTECTHFS_DEFAULT }, {"core.protecthfs", NULL, 0, GIT_PROTECTHFS_DEFAULT },
{"core.protectntfs", NULL, 0, GIT_PROTECTNTFS_DEFAULT }, {"core.protectntfs", NULL, 0, GIT_PROTECTNTFS_DEFAULT },
{"core.fsyncobjectfiles", NULL, 0, GIT_FSYNCOBJECTFILES_DEFAULT }, {"core.fsyncobjectfiles", NULL, 0, GIT_FSYNCOBJECTFILES_DEFAULT },
}; };
int git_config__cvar(int *out, git_config *config, git_cvar_cached cvar) int git_config__configmap_lookup(int *out, git_config *config, git_configmap_item item)
{ {
int error = 0; int error = 0;
struct map_data *data = &_cvar_maps[(int)cvar]; struct map_data *data = &_configmaps[(int)item];
git_config_entry *entry; git_config_entry *entry;
if ((error = git_config__lookup_entry(&entry, config, data->cvar_name, false)) < 0) if ((error = git_config__lookup_entry(&entry, config, data->name, false)) < 0)
return error; return error;
if (!entry) if (!entry)
...@@ -109,29 +109,29 @@ int git_config__cvar(int *out, git_config *config, git_cvar_cached cvar) ...@@ -109,29 +109,29 @@ int git_config__cvar(int *out, git_config *config, git_cvar_cached cvar)
return error; return error;
} }
int git_repository__cvar(int *out, git_repository *repo, git_cvar_cached cvar) int git_repository__configmap_lookup(int *out, git_repository *repo, git_configmap_item item)
{ {
*out = repo->cvar_cache[(int)cvar]; *out = repo->configmap_cache[(int)item];
if (*out == GIT_CVAR_NOT_CACHED) { if (*out == GIT_CONFIGMAP_NOT_CACHED) {
int error; int error;
git_config *config; git_config *config;
if ((error = git_repository_config__weakptr(&config, repo)) < 0 || if ((error = git_repository_config__weakptr(&config, repo)) < 0 ||
(error = git_config__cvar(out, config, cvar)) < 0) (error = git_config__configmap_lookup(out, config, item)) < 0)
return error; return error;
repo->cvar_cache[(int)cvar] = *out; repo->configmap_cache[(int)item] = *out;
} }
return 0; return 0;
} }
void git_repository__cvar_cache_clear(git_repository *repo) void git_repository__configmap_lookup_cache_clear(git_repository *repo)
{ {
int i; int i;
for (i = 0; i < GIT_CVAR_CACHE_MAX; ++i) for (i = 0; i < GIT_CONFIGMAP_CACHE_MAX; ++i)
repo->cvar_cache[i] = GIT_CVAR_NOT_CACHED; repo->configmap_cache[i] = GIT_CONFIGMAP_NOT_CACHED;
} }
...@@ -58,7 +58,7 @@ static git_crlf_t check_crlf(const char *value) ...@@ -58,7 +58,7 @@ static git_crlf_t check_crlf(const char *value)
return GIT_CRLF_UNDEFINED; return GIT_CRLF_UNDEFINED;
} }
static git_cvar_value check_eol(const char *value) static git_configmap_value check_eol(const char *value)
{ {
if (GIT_ATTR_IS_UNSPECIFIED(value)) if (GIT_ATTR_IS_UNSPECIFIED(value))
; ;
...@@ -127,7 +127,7 @@ static int text_eol_is_crlf(struct crlf_attrs *ca) ...@@ -127,7 +127,7 @@ static int text_eol_is_crlf(struct crlf_attrs *ca)
return 0; return 0;
} }
static git_cvar_value output_eol(struct crlf_attrs *ca) static git_configmap_value output_eol(struct crlf_attrs *ca)
{ {
switch (ca->crlf_action) { switch (ca->crlf_action) {
case GIT_CRLF_BINARY: case GIT_CRLF_BINARY:
...@@ -293,12 +293,12 @@ static int convert_attrs( ...@@ -293,12 +293,12 @@ static int convert_attrs(
memset(ca, 0, sizeof(struct crlf_attrs)); memset(ca, 0, sizeof(struct crlf_attrs));
if ((error = git_repository__cvar(&ca->auto_crlf, if ((error = git_repository__configmap_lookup(&ca->auto_crlf,
git_filter_source_repo(src), GIT_CVAR_AUTO_CRLF)) < 0 || git_filter_source_repo(src), GIT_CONFIGMAP_AUTO_CRLF)) < 0 ||
(error = git_repository__cvar(&ca->safe_crlf, (error = git_repository__configmap_lookup(&ca->safe_crlf,
git_filter_source_repo(src), GIT_CVAR_SAFE_CRLF)) < 0 || git_filter_source_repo(src), GIT_CONFIGMAP_SAFE_CRLF)) < 0 ||
(error = git_repository__cvar(&ca->core_eol, (error = git_repository__configmap_lookup(&ca->core_eol,
git_filter_source_repo(src), GIT_CVAR_EOL)) < 0) git_filter_source_repo(src), GIT_CONFIGMAP_EOL)) < 0)
return error; return error;
/* downgrade FAIL to WARN if ALLOW_UNSAFE option is used */ /* downgrade FAIL to WARN if ALLOW_UNSAFE option is used */
......
...@@ -290,8 +290,8 @@ static int diff_file_content_load_workdir_symlink( ...@@ -290,8 +290,8 @@ static int diff_file_content_load_workdir_symlink(
ssize_t alloc_len, read_len; ssize_t alloc_len, read_len;
int symlink_supported, error; int symlink_supported, error;
if ((error = git_repository__cvar( if ((error = git_repository__configmap_lookup(
&symlink_supported, fc->repo, GIT_CVAR_SYMLINKS)) < 0) &symlink_supported, fc->repo, GIT_CONFIGMAP_SYMLINKS)) < 0)
return -1; return -1;
if (!symlink_supported) if (!symlink_supported)
......
...@@ -472,17 +472,17 @@ static int diff_generated_apply_options( ...@@ -472,17 +472,17 @@ static int diff_generated_apply_options(
if ((val = git_repository_config_snapshot(&cfg, repo)) < 0) if ((val = git_repository_config_snapshot(&cfg, repo)) < 0)
return val; return val;
if (!git_config__cvar(&val, cfg, GIT_CVAR_SYMLINKS) && val) if (!git_config__configmap_lookup(&val, cfg, GIT_CONFIGMAP_SYMLINKS) && val)
diff->diffcaps |= GIT_DIFFCAPS_HAS_SYMLINKS; diff->diffcaps |= GIT_DIFFCAPS_HAS_SYMLINKS;
if (!git_config__cvar(&val, cfg, GIT_CVAR_IGNORESTAT) && val) if (!git_config__configmap_lookup(&val, cfg, GIT_CONFIGMAP_IGNORESTAT) && val)
diff->diffcaps |= GIT_DIFFCAPS_IGNORE_STAT; diff->diffcaps |= GIT_DIFFCAPS_IGNORE_STAT;
if ((diff->base.opts.flags & GIT_DIFF_IGNORE_FILEMODE) == 0 && if ((diff->base.opts.flags & GIT_DIFF_IGNORE_FILEMODE) == 0 &&
!git_config__cvar(&val, cfg, GIT_CVAR_FILEMODE) && val) !git_config__configmap_lookup(&val, cfg, GIT_CONFIGMAP_FILEMODE) && val)
diff->diffcaps |= GIT_DIFFCAPS_TRUST_MODE_BITS; diff->diffcaps |= GIT_DIFFCAPS_TRUST_MODE_BITS;
if (!git_config__cvar(&val, cfg, GIT_CVAR_TRUSTCTIME) && val) if (!git_config__configmap_lookup(&val, cfg, GIT_CONFIGMAP_TRUSTCTIME) && val)
diff->diffcaps |= GIT_DIFFCAPS_TRUST_CTIME; diff->diffcaps |= GIT_DIFFCAPS_TRUST_CTIME;
/* Don't set GIT_DIFFCAPS_USE_DEV - compile time option in core git */ /* Don't set GIT_DIFFCAPS_USE_DEV - compile time option in core git */
......
...@@ -48,7 +48,7 @@ static int diff_print_info_init__common( ...@@ -48,7 +48,7 @@ static int diff_print_info_init__common(
if (!pi->id_strlen) { if (!pi->id_strlen) {
if (!repo) if (!repo)
pi->id_strlen = GIT_ABBREV_DEFAULT; pi->id_strlen = GIT_ABBREV_DEFAULT;
else if (git_repository__cvar(&pi->id_strlen, repo, GIT_CVAR_ABBREV) < 0) else if (git_repository__configmap_lookup(&pi->id_strlen, repo, GIT_CONFIGMAP_ABBREV) < 0)
return -1; return -1;
} }
......
...@@ -172,7 +172,7 @@ static int parse_ignore_file( ...@@ -172,7 +172,7 @@ static int parse_ignore_file(
GIT_UNUSED(allow_macros); GIT_UNUSED(allow_macros);
if (git_repository__cvar(&ignore_case, repo, GIT_CVAR_IGNORECASE) < 0) if (git_repository__configmap_lookup(&ignore_case, repo, GIT_CONFIGMAP_IGNORECASE) < 0)
git_error_clear(); git_error_clear();
/* if subdir file path, convert context for file paths */ /* if subdir file path, convert context for file paths */
...@@ -298,8 +298,8 @@ int git_ignore__for_path( ...@@ -298,8 +298,8 @@ int git_ignore__for_path(
ignores->repo = repo; ignores->repo = repo;
/* Read the ignore_case flag */ /* Read the ignore_case flag */
if ((error = git_repository__cvar( if ((error = git_repository__configmap_lookup(
&ignores->ignore_case, repo, GIT_CVAR_IGNORECASE)) < 0) &ignores->ignore_case, repo, GIT_CONFIGMAP_IGNORECASE)) < 0)
goto cleanup; goto cleanup;
if ((error = git_attr_cache__init(repo)) < 0) if ((error = git_attr_cache__init(repo)) < 0)
......
...@@ -570,11 +570,11 @@ int git_index_set_caps(git_index *index, int caps) ...@@ -570,11 +570,11 @@ int git_index_set_caps(git_index *index, int caps)
return create_index_error( return create_index_error(
-1, "cannot access repository to set index caps"); -1, "cannot access repository to set index caps");
if (!git_repository__cvar(&val, repo, GIT_CVAR_IGNORECASE)) if (!git_repository__configmap_lookup(&val, repo, GIT_CONFIGMAP_IGNORECASE))
index->ignore_case = (val != 0); index->ignore_case = (val != 0);
if (!git_repository__cvar(&val, repo, GIT_CVAR_FILEMODE)) if (!git_repository__configmap_lookup(&val, repo, GIT_CONFIGMAP_FILEMODE))
index->distrust_filemode = (val == 0); index->distrust_filemode = (val == 0);
if (!git_repository__cvar(&val, repo, GIT_CVAR_SYMLINKS)) if (!git_repository__configmap_lookup(&val, repo, GIT_CONFIGMAP_SYMLINKS))
index->no_symlinks = (val == 0); index->no_symlinks = (val == 0);
} }
else { else {
......
...@@ -145,7 +145,7 @@ static int iterator_init_common( ...@@ -145,7 +145,7 @@ static int iterator_init_common(
(iter->flags & GIT_ITERATOR_PRECOMPOSE_UNICODE) == 0 && (iter->flags & GIT_ITERATOR_PRECOMPOSE_UNICODE) == 0 &&
(iter->flags & GIT_ITERATOR_DONT_PRECOMPOSE_UNICODE) == 0) { (iter->flags & GIT_ITERATOR_DONT_PRECOMPOSE_UNICODE) == 0) {
if (git_repository__cvar(&precompose, repo, GIT_CVAR_PRECOMPOSE) < 0) if (git_repository__configmap_lookup(&precompose, repo, GIT_CONFIGMAP_PRECOMPOSE) < 0)
git_error_clear(); git_error_clear();
else if (precompose) else if (precompose)
iter->flags |= GIT_ITERATOR_PRECOMPOSE_UNICODE; iter->flags |= GIT_ITERATOR_PRECOMPOSE_UNICODE;
......
...@@ -496,7 +496,7 @@ int git_object_short_id(git_buf *out, const git_object *obj) ...@@ -496,7 +496,7 @@ int git_object_short_id(git_buf *out, const git_object *obj)
git_buf_sanitize(out); git_buf_sanitize(out);
repo = git_object_owner(obj); repo = git_object_owner(obj);
if ((error = git_repository__cvar(&len, repo, GIT_CVAR_ABBREV)) < 0) if ((error = git_repository__configmap_lookup(&len, repo, GIT_CONFIGMAP_ABBREV)) < 0)
return error; return error;
if ((error = git_repository_odb(&odb, repo)) < 0) if ((error = git_repository_odb(&odb, repo)) < 0)
......
...@@ -666,7 +666,7 @@ int git_odb__set_caps(git_odb *odb, int caps) ...@@ -666,7 +666,7 @@ int git_odb__set_caps(git_odb *odb, int caps)
return -1; return -1;
} }
if (!git_repository__cvar(&val, repo, GIT_CVAR_FSYNCOBJECTFILES)) if (!git_repository__configmap_lookup(&val, repo, GIT_CONFIGMAP_FSYNCOBJECTFILES))
odb->do_fsync = !!val; odb->do_fsync = !!val;
} }
......
...@@ -1397,7 +1397,7 @@ int git_packbuilder_write( ...@@ -1397,7 +1397,7 @@ int git_packbuilder_write(
&indexer, path, mode, pb->odb, &opts) < 0) &indexer, path, mode, pb->odb, &opts) < 0)
return -1; return -1;
if (!git_repository__cvar(&t, pb->repo, GIT_CVAR_FSYNCOBJECTFILES) && t) if (!git_repository__configmap_lookup(&t, pb->repo, GIT_CONFIGMAP_FSYNCOBJECTFILES) && t)
git_indexer__set_fsync(indexer, 1); git_indexer__set_fsync(indexer, 1);
ctx.indexer = indexer; ctx.indexer = indexer;
......
...@@ -1832,12 +1832,12 @@ GIT_INLINE(unsigned int) dotgit_flags( ...@@ -1832,12 +1832,12 @@ GIT_INLINE(unsigned int) dotgit_flags(
#endif #endif
if (repo && !protectHFS) if (repo && !protectHFS)
error = git_repository__cvar(&protectHFS, repo, GIT_CVAR_PROTECTHFS); error = git_repository__configmap_lookup(&protectHFS, repo, GIT_CONFIGMAP_PROTECTHFS);
if (!error && protectHFS) if (!error && protectHFS)
flags |= GIT_PATH_REJECT_DOT_GIT_HFS; flags |= GIT_PATH_REJECT_DOT_GIT_HFS;
if (repo && !protectNTFS) if (repo && !protectNTFS)
error = git_repository__cvar(&protectNTFS, repo, GIT_CVAR_PROTECTNTFS); error = git_repository__configmap_lookup(&protectNTFS, repo, GIT_CONFIGMAP_PROTECTNTFS);
if (!error && protectNTFS) if (!error && protectNTFS)
flags |= GIT_PATH_REJECT_DOT_GIT_NTFS; flags |= GIT_PATH_REJECT_DOT_GIT_NTFS;
......
...@@ -1104,7 +1104,7 @@ static int should_write_reflog(int *write, git_repository *repo, const char *nam ...@@ -1104,7 +1104,7 @@ static int should_write_reflog(int *write, git_repository *repo, const char *nam
{ {
int error, logall; int error, logall;
error = git_repository__cvar(&logall, repo, GIT_CVAR_LOGALLREFUPDATES); error = git_repository__configmap_lookup(&logall, repo, GIT_CONFIGMAP_LOGALLREFUPDATES);
if (error < 0) if (error < 0)
return error; return error;
...@@ -2114,15 +2114,15 @@ int git_refdb_backend_fs( ...@@ -2114,15 +2114,15 @@ int git_refdb_backend_fs(
git_buf_dispose(&gitpath); git_buf_dispose(&gitpath);
if (!git_repository__cvar(&t, backend->repo, GIT_CVAR_IGNORECASE) && t) { if (!git_repository__configmap_lookup(&t, backend->repo, GIT_CONFIGMAP_IGNORECASE) && t) {
backend->iterator_flags |= GIT_ITERATOR_IGNORE_CASE; backend->iterator_flags |= GIT_ITERATOR_IGNORE_CASE;
backend->direach_flags |= GIT_PATH_DIR_IGNORE_CASE; backend->direach_flags |= GIT_PATH_DIR_IGNORE_CASE;
} }
if (!git_repository__cvar(&t, backend->repo, GIT_CVAR_PRECOMPOSE) && t) { if (!git_repository__configmap_lookup(&t, backend->repo, GIT_CONFIGMAP_PRECOMPOSE) && t) {
backend->iterator_flags |= GIT_ITERATOR_PRECOMPOSE_UNICODE; backend->iterator_flags |= GIT_ITERATOR_PRECOMPOSE_UNICODE;
backend->direach_flags |= GIT_PATH_DIR_PRECOMPOSE_UNICODE; backend->direach_flags |= GIT_PATH_DIR_PRECOMPOSE_UNICODE;
} }
if ((!git_repository__cvar(&t, backend->repo, GIT_CVAR_FSYNCOBJECTFILES) && t) || if ((!git_repository__configmap_lookup(&t, backend->repo, GIT_CONFIGMAP_FSYNCOBJECTFILES) && t) ||
git_repository__fsync_gitdir) git_repository__fsync_gitdir)
backend->fsync = 1; backend->fsync = 1;
backend->iterator_flags |= GIT_ITERATOR_DESCEND_SYMLINKS; backend->iterator_flags |= GIT_ITERATOR_DESCEND_SYMLINKS;
......
...@@ -188,7 +188,7 @@ static int reference_normalize_for_repo( ...@@ -188,7 +188,7 @@ static int reference_normalize_for_repo(
int precompose; int precompose;
unsigned int flags = GIT_REFERENCE_FORMAT_ALLOW_ONELEVEL; unsigned int flags = GIT_REFERENCE_FORMAT_ALLOW_ONELEVEL;
if (!git_repository__cvar(&precompose, repo, GIT_CVAR_PRECOMPOSE) && if (!git_repository__configmap_lookup(&precompose, repo, GIT_CONFIGMAP_PRECOMPOSE) &&
precompose) precompose)
flags |= GIT_REFERENCE_FORMAT__PRECOMPOSE_UNICODE; flags |= GIT_REFERENCE_FORMAT__PRECOMPOSE_UNICODE;
......
...@@ -122,7 +122,7 @@ static void set_config(git_repository *repo, git_config *config) ...@@ -122,7 +122,7 @@ static void set_config(git_repository *repo, git_config *config)
git_config_free(config); git_config_free(config);
} }
git_repository__cvar_cache_clear(repo); git_repository__configmap_lookup_cache_clear(repo);
} }
static void set_index(git_repository *repo, git_index *index) static void set_index(git_repository *repo, git_index *index)
...@@ -239,8 +239,8 @@ static git_repository *repository_alloc(void) ...@@ -239,8 +239,8 @@ static git_repository *repository_alloc(void)
if (!repo->reserved_names.ptr) if (!repo->reserved_names.ptr)
goto on_error; goto on_error;
/* set all the entries in the cvar cache to `unset` */ /* set all the entries in the configmap cache to `unset` */
git_repository__cvar_cache_clear(repo); git_repository__configmap_lookup_cache_clear(repo);
return repo; return repo;
...@@ -1287,8 +1287,8 @@ bool git_repository__reserved_names( ...@@ -1287,8 +1287,8 @@ bool git_repository__reserved_names(
int (*prefixcmp)(const char *, const char *); int (*prefixcmp)(const char *, const char *);
int error, ignorecase; int error, ignorecase;
error = git_repository__cvar( error = git_repository__configmap_lookup(
&ignorecase, repo, GIT_CVAR_IGNORECASE); &ignorecase, repo, GIT_CONFIGMAP_IGNORECASE);
prefixcmp = (error || ignorecase) ? git__prefixcmp_icase : prefixcmp = (error || ignorecase) ? git__prefixcmp_icase :
git__prefixcmp; git__prefixcmp;
...@@ -1660,7 +1660,7 @@ int git_repository_reinit_filesystem(git_repository *repo, int recurse) ...@@ -1660,7 +1660,7 @@ int git_repository_reinit_filesystem(git_repository *repo, int recurse)
git_config_free(config); git_config_free(config);
git_buf_dispose(&path); git_buf_dispose(&path);
git_repository__cvar_cache_clear(repo); git_repository__configmap_lookup_cache_clear(repo);
if (!repo->is_bare && recurse) if (!repo->is_bare && recurse)
(void)git_submodule_foreach(repo, repo_reinit_submodule_fs, NULL); (void)git_submodule_foreach(repo, repo_reinit_submodule_fs, NULL);
......
...@@ -37,34 +37,34 @@ extern bool git_repository__fsync_gitdir; ...@@ -37,34 +37,34 @@ extern bool git_repository__fsync_gitdir;
/** Cvar cache identifiers */ /** Cvar cache identifiers */
typedef enum { typedef enum {
GIT_CVAR_AUTO_CRLF = 0, /* core.autocrlf */ GIT_CONFIGMAP_AUTO_CRLF = 0, /* core.autocrlf */
GIT_CVAR_EOL, /* core.eol */ GIT_CONFIGMAP_EOL, /* core.eol */
GIT_CVAR_SYMLINKS, /* core.symlinks */ GIT_CONFIGMAP_SYMLINKS, /* core.symlinks */
GIT_CVAR_IGNORECASE, /* core.ignorecase */ GIT_CONFIGMAP_IGNORECASE, /* core.ignorecase */
GIT_CVAR_FILEMODE, /* core.filemode */ GIT_CONFIGMAP_FILEMODE, /* core.filemode */
GIT_CVAR_IGNORESTAT, /* core.ignorestat */ GIT_CONFIGMAP_IGNORESTAT, /* core.ignorestat */
GIT_CVAR_TRUSTCTIME, /* core.trustctime */ GIT_CONFIGMAP_TRUSTCTIME, /* core.trustctime */
GIT_CVAR_ABBREV, /* core.abbrev */ GIT_CONFIGMAP_ABBREV, /* core.abbrev */
GIT_CVAR_PRECOMPOSE, /* core.precomposeunicode */ GIT_CONFIGMAP_PRECOMPOSE, /* core.precomposeunicode */
GIT_CVAR_SAFE_CRLF, /* core.safecrlf */ GIT_CONFIGMAP_SAFE_CRLF, /* core.safecrlf */
GIT_CVAR_LOGALLREFUPDATES, /* core.logallrefupdates */ GIT_CONFIGMAP_LOGALLREFUPDATES, /* core.logallrefupdates */
GIT_CVAR_PROTECTHFS, /* core.protectHFS */ GIT_CONFIGMAP_PROTECTHFS, /* core.protectHFS */
GIT_CVAR_PROTECTNTFS, /* core.protectNTFS */ GIT_CONFIGMAP_PROTECTNTFS, /* core.protectNTFS */
GIT_CVAR_FSYNCOBJECTFILES, /* core.fsyncObjectFiles */ GIT_CONFIGMAP_FSYNCOBJECTFILES, /* core.fsyncObjectFiles */
GIT_CVAR_CACHE_MAX GIT_CONFIGMAP_CACHE_MAX
} git_cvar_cached; } git_configmap_item;
/** /**
* CVAR value enumerations * Configuration map value enumerations
* *
* These are the values that are actually stored in the cvar cache, instead * These are the values that are actually stored in the configmap cache,
* of their string equivalents. These values are internal and symbolic; * instead of their string equivalents. These values are internal and
* make sure that none of them is set to `-1`, since that is the unique * symbolic; make sure that none of them is set to `-1`, since that is
* identifier for "not cached" * the unique identifier for "not cached"
*/ */
typedef enum { typedef enum {
/* The value hasn't been loaded from the cache yet */ /* The value hasn't been loaded from the cache yet */
GIT_CVAR_NOT_CACHED = -1, GIT_CONFIGMAP_NOT_CACHED = -1,
/* core.safecrlf: false, 'fail', 'warn' */ /* core.safecrlf: false, 'fail', 'warn' */
GIT_SAFE_CRLF_FALSE = 0, GIT_SAFE_CRLF_FALSE = 0,
...@@ -89,34 +89,34 @@ typedef enum { ...@@ -89,34 +89,34 @@ typedef enum {
GIT_EOL_DEFAULT = GIT_EOL_NATIVE, GIT_EOL_DEFAULT = GIT_EOL_NATIVE,
/* core.symlinks: bool */ /* core.symlinks: bool */
GIT_SYMLINKS_DEFAULT = GIT_CVAR_TRUE, GIT_SYMLINKS_DEFAULT = GIT_CONFIGMAP_TRUE,
/* core.ignorecase */ /* core.ignorecase */
GIT_IGNORECASE_DEFAULT = GIT_CVAR_FALSE, GIT_IGNORECASE_DEFAULT = GIT_CONFIGMAP_FALSE,
/* core.filemode */ /* core.filemode */
GIT_FILEMODE_DEFAULT = GIT_CVAR_TRUE, GIT_FILEMODE_DEFAULT = GIT_CONFIGMAP_TRUE,
/* core.ignorestat */ /* core.ignorestat */
GIT_IGNORESTAT_DEFAULT = GIT_CVAR_FALSE, GIT_IGNORESTAT_DEFAULT = GIT_CONFIGMAP_FALSE,
/* core.trustctime */ /* core.trustctime */
GIT_TRUSTCTIME_DEFAULT = GIT_CVAR_TRUE, GIT_TRUSTCTIME_DEFAULT = GIT_CONFIGMAP_TRUE,
/* core.abbrev */ /* core.abbrev */
GIT_ABBREV_DEFAULT = 7, GIT_ABBREV_DEFAULT = 7,
/* core.precomposeunicode */ /* core.precomposeunicode */
GIT_PRECOMPOSE_DEFAULT = GIT_CVAR_FALSE, GIT_PRECOMPOSE_DEFAULT = GIT_CONFIGMAP_FALSE,
/* core.safecrlf */ /* core.safecrlf */
GIT_SAFE_CRLF_DEFAULT = GIT_CVAR_FALSE, GIT_SAFE_CRLF_DEFAULT = GIT_CONFIGMAP_FALSE,
/* core.logallrefupdates */ /* core.logallrefupdates */
GIT_LOGALLREFUPDATES_FALSE = GIT_CVAR_FALSE, GIT_LOGALLREFUPDATES_FALSE = GIT_CONFIGMAP_FALSE,
GIT_LOGALLREFUPDATES_TRUE = GIT_CVAR_TRUE, GIT_LOGALLREFUPDATES_TRUE = GIT_CONFIGMAP_TRUE,
GIT_LOGALLREFUPDATES_UNSET = 2, GIT_LOGALLREFUPDATES_UNSET = 2,
GIT_LOGALLREFUPDATES_ALWAYS = 3, GIT_LOGALLREFUPDATES_ALWAYS = 3,
GIT_LOGALLREFUPDATES_DEFAULT = GIT_LOGALLREFUPDATES_UNSET, GIT_LOGALLREFUPDATES_DEFAULT = GIT_LOGALLREFUPDATES_UNSET,
/* core.protectHFS */ /* core.protectHFS */
GIT_PROTECTHFS_DEFAULT = GIT_CVAR_FALSE, GIT_PROTECTHFS_DEFAULT = GIT_CONFIGMAP_FALSE,
/* core.protectNTFS */ /* core.protectNTFS */
GIT_PROTECTNTFS_DEFAULT = GIT_CVAR_FALSE, GIT_PROTECTNTFS_DEFAULT = GIT_CONFIGMAP_FALSE,
/* core.fsyncObjectFiles */ /* core.fsyncObjectFiles */
GIT_FSYNCOBJECTFILES_DEFAULT = GIT_CVAR_FALSE, GIT_FSYNCOBJECTFILES_DEFAULT = GIT_CONFIGMAP_FALSE,
} git_cvar_value; } git_configmap_value;
/* internal repository init flags */ /* internal repository init flags */
enum { enum {
...@@ -154,7 +154,7 @@ struct git_repository { ...@@ -154,7 +154,7 @@ struct git_repository {
git_atomic attr_session_key; git_atomic attr_session_key;
git_cvar_value cvar_cache[GIT_CVAR_CACHE_MAX]; git_configmap_value configmap_cache[GIT_CONFIGMAP_CACHE_MAX];
git_strmap *submodule_cache; git_strmap *submodule_cache;
}; };
...@@ -208,13 +208,13 @@ int git_repository_refdb__weakptr(git_refdb **out, git_repository *repo); ...@@ -208,13 +208,13 @@ int git_repository_refdb__weakptr(git_refdb **out, git_repository *repo);
int git_repository_index__weakptr(git_index **out, git_repository *repo); int git_repository_index__weakptr(git_index **out, git_repository *repo);
/* /*
* CVAR cache * Configuration map cache
* *
* Efficient access to the most used config variables of a repository. * Efficient access to the most used config variables of a repository.
* The cache is cleared every time the config backend is replaced. * The cache is cleared every time the config backend is replaced.
*/ */
int git_repository__cvar(int *out, git_repository *repo, git_cvar_cached cvar); int git_repository__configmap_lookup(int *out, git_repository *repo, git_configmap_item item);
void git_repository__cvar_cache_clear(git_repository *repo); void git_repository__configmap_lookup_cache_clear(git_repository *repo);
GIT_INLINE(int) git_repository__ensure_not_bare( GIT_INLINE(int) git_repository__ensure_not_bare(
git_repository *repo, git_repository *repo,
......
...@@ -412,7 +412,7 @@ static int commit_worktree( ...@@ -412,7 +412,7 @@ static int commit_worktree(
goto cleanup; goto cleanup;
if ((error = git_index_new(&i_index)) < 0 || if ((error = git_index_new(&i_index)) < 0 ||
(error = git_repository__cvar(&ignorecase, repo, GIT_CVAR_IGNORECASE)) < 0) (error = git_repository__configmap_lookup(&ignorecase, repo, GIT_CONFIGMAP_IGNORECASE)) < 0)
goto cleanup; goto cleanup;
git_index__set_ignore_case(i_index, ignorecase); git_index__set_ignore_case(i_index, ignorecase);
......
...@@ -26,28 +26,28 @@ ...@@ -26,28 +26,28 @@
#define GIT_MODULES_FILE ".gitmodules" #define GIT_MODULES_FILE ".gitmodules"
static git_cvar_map _sm_update_map[] = { static git_configmap _sm_update_map[] = {
{GIT_CVAR_STRING, "checkout", GIT_SUBMODULE_UPDATE_CHECKOUT}, {GIT_CONFIGMAP_STRING, "checkout", GIT_SUBMODULE_UPDATE_CHECKOUT},
{GIT_CVAR_STRING, "rebase", GIT_SUBMODULE_UPDATE_REBASE}, {GIT_CONFIGMAP_STRING, "rebase", GIT_SUBMODULE_UPDATE_REBASE},
{GIT_CVAR_STRING, "merge", GIT_SUBMODULE_UPDATE_MERGE}, {GIT_CONFIGMAP_STRING, "merge", GIT_SUBMODULE_UPDATE_MERGE},
{GIT_CVAR_STRING, "none", GIT_SUBMODULE_UPDATE_NONE}, {GIT_CONFIGMAP_STRING, "none", GIT_SUBMODULE_UPDATE_NONE},
{GIT_CVAR_FALSE, NULL, GIT_SUBMODULE_UPDATE_NONE}, {GIT_CONFIGMAP_FALSE, NULL, GIT_SUBMODULE_UPDATE_NONE},
{GIT_CVAR_TRUE, NULL, GIT_SUBMODULE_UPDATE_CHECKOUT}, {GIT_CONFIGMAP_TRUE, NULL, GIT_SUBMODULE_UPDATE_CHECKOUT},
}; };
static git_cvar_map _sm_ignore_map[] = { static git_configmap _sm_ignore_map[] = {
{GIT_CVAR_STRING, "none", GIT_SUBMODULE_IGNORE_NONE}, {GIT_CONFIGMAP_STRING, "none", GIT_SUBMODULE_IGNORE_NONE},
{GIT_CVAR_STRING, "untracked", GIT_SUBMODULE_IGNORE_UNTRACKED}, {GIT_CONFIGMAP_STRING, "untracked", GIT_SUBMODULE_IGNORE_UNTRACKED},
{GIT_CVAR_STRING, "dirty", GIT_SUBMODULE_IGNORE_DIRTY}, {GIT_CONFIGMAP_STRING, "dirty", GIT_SUBMODULE_IGNORE_DIRTY},
{GIT_CVAR_STRING, "all", GIT_SUBMODULE_IGNORE_ALL}, {GIT_CONFIGMAP_STRING, "all", GIT_SUBMODULE_IGNORE_ALL},
{GIT_CVAR_FALSE, NULL, GIT_SUBMODULE_IGNORE_NONE}, {GIT_CONFIGMAP_FALSE, NULL, GIT_SUBMODULE_IGNORE_NONE},
{GIT_CVAR_TRUE, NULL, GIT_SUBMODULE_IGNORE_ALL}, {GIT_CONFIGMAP_TRUE, NULL, GIT_SUBMODULE_IGNORE_ALL},
}; };
static git_cvar_map _sm_recurse_map[] = { static git_configmap _sm_recurse_map[] = {
{GIT_CVAR_STRING, "on-demand", GIT_SUBMODULE_RECURSE_ONDEMAND}, {GIT_CONFIGMAP_STRING, "on-demand", GIT_SUBMODULE_RECURSE_ONDEMAND},
{GIT_CVAR_FALSE, NULL, GIT_SUBMODULE_RECURSE_NO}, {GIT_CONFIGMAP_FALSE, NULL, GIT_SUBMODULE_RECURSE_NO},
{GIT_CVAR_TRUE, NULL, GIT_SUBMODULE_RECURSE_YES}, {GIT_CONFIGMAP_TRUE, NULL, GIT_SUBMODULE_RECURSE_YES},
}; };
enum { enum {
...@@ -989,9 +989,9 @@ cleanup: ...@@ -989,9 +989,9 @@ cleanup:
return error; return error;
} }
static int write_mapped_var(git_repository *repo, const char *name, git_cvar_map *maps, size_t nmaps, const char *var, int ival) static int write_mapped_var(git_repository *repo, const char *name, git_configmap *maps, size_t nmaps, const char *var, int ival)
{ {
git_cvar_t type; git_configmap_t type;
const char *val; const char *val;
if (git_config_lookup_map_enum(&type, &val, maps, nmaps, ival) < 0) { if (git_config_lookup_map_enum(&type, &val, maps, nmaps, ival) < 0) {
...@@ -999,7 +999,7 @@ static int write_mapped_var(git_repository *repo, const char *name, git_cvar_map ...@@ -999,7 +999,7 @@ static int write_mapped_var(git_repository *repo, const char *name, git_cvar_map
return -1; return -1;
} }
if (type == GIT_CVAR_TRUE) if (type == GIT_CONFIGMAP_TRUE)
val = "true"; val = "true";
return write_var(repo, name, var, val); return write_var(repo, name, var, val);
......
...@@ -192,7 +192,7 @@ static void ensure_workdir_link( ...@@ -192,7 +192,7 @@ static void ensure_workdir_link(
{ {
int symlinks; int symlinks;
cl_git_pass(git_repository__cvar(&symlinks, repo, GIT_CVAR_SYMLINKS)); cl_git_pass(git_repository__configmap_lookup(&symlinks, repo, GIT_CONFIGMAP_SYMLINKS));
if (!symlinks) { if (!symlinks) {
ensure_workdir_contents(path, target); ensure_workdir_contents(path, target);
......
...@@ -96,7 +96,7 @@ static int symlink_or_fake(git_repository *repo, const char *a, const char *b) ...@@ -96,7 +96,7 @@ static int symlink_or_fake(git_repository *repo, const char *a, const char *b)
{ {
int symlinks; int symlinks;
cl_git_pass(git_repository__cvar(&symlinks, repo, GIT_CVAR_SYMLINKS)); cl_git_pass(git_repository__configmap_lookup(&symlinks, repo, GIT_CONFIGMAP_SYMLINKS));
if (symlinks) if (symlinks)
return p_symlink(a, b); return p_symlink(a, b);
......
...@@ -2112,7 +2112,7 @@ void test_diff_workdir__symlink_changed_on_non_symlink_platform(void) ...@@ -2112,7 +2112,7 @@ void test_diff_workdir__symlink_changed_on_non_symlink_platform(void)
g_repo = cl_git_sandbox_init("unsymlinked.git"); g_repo = cl_git_sandbox_init("unsymlinked.git");
cl_git_pass(git_repository__cvar(&symlinks, g_repo, GIT_CVAR_SYMLINKS)); cl_git_pass(git_repository__configmap_lookup(&symlinks, g_repo, GIT_CONFIGMAP_SYMLINKS));
if (symlinks) if (symlinks)
cl_skip(); cl_skip();
......
...@@ -338,7 +338,7 @@ void test_index_bypath__add_honors_symlink(void) ...@@ -338,7 +338,7 @@ void test_index_bypath__add_honors_symlink(void)
git_index_entry new_entry; git_index_entry new_entry;
int symlinks; int symlinks;
cl_git_pass(git_repository__cvar(&symlinks, g_repo, GIT_CVAR_SYMLINKS)); cl_git_pass(git_repository__configmap_lookup(&symlinks, g_repo, GIT_CONFIGMAP_SYMLINKS));
if (symlinks) if (symlinks)
cl_skip(); cl_skip();
......
...@@ -104,9 +104,9 @@ void test_repo_config__read_with_no_configs_at_all(void) ...@@ -104,9 +104,9 @@ void test_repo_config__read_with_no_configs_at_all(void)
cl_assert(!git_path_isfile("empty_standard_repo/.git/config")); cl_assert(!git_path_isfile("empty_standard_repo/.git/config"));
cl_git_pass(git_repository_open(&repo, "empty_standard_repo")); cl_git_pass(git_repository_open(&repo, "empty_standard_repo"));
git_repository__cvar_cache_clear(repo); git_repository__configmap_lookup_cache_clear(repo);
val = -1; val = -1;
cl_git_pass(git_repository__cvar(&val, repo, GIT_CVAR_ABBREV)); cl_git_pass(git_repository__configmap_lookup(&val, repo, GIT_CONFIGMAP_ABBREV));
cl_assert_equal_i(GIT_ABBREV_DEFAULT, val); cl_assert_equal_i(GIT_ABBREV_DEFAULT, val);
git_repository_free(repo); git_repository_free(repo);
...@@ -121,9 +121,9 @@ void test_repo_config__read_with_no_configs_at_all(void) ...@@ -121,9 +121,9 @@ void test_repo_config__read_with_no_configs_at_all(void)
GIT_OPT_SET_SEARCH_PATH, GIT_CONFIG_LEVEL_SYSTEM, path.ptr)); GIT_OPT_SET_SEARCH_PATH, GIT_CONFIG_LEVEL_SYSTEM, path.ptr));
cl_git_pass(git_repository_open(&repo, "empty_standard_repo")); cl_git_pass(git_repository_open(&repo, "empty_standard_repo"));
git_repository__cvar_cache_clear(repo); git_repository__configmap_lookup_cache_clear(repo);
val = -1; val = -1;
cl_git_pass(git_repository__cvar(&val, repo, GIT_CVAR_ABBREV)); cl_git_pass(git_repository__configmap_lookup(&val, repo, GIT_CONFIGMAP_ABBREV));
cl_assert_equal_i(10, val); cl_assert_equal_i(10, val);
git_repository_free(repo); git_repository_free(repo);
...@@ -136,9 +136,9 @@ void test_repo_config__read_with_no_configs_at_all(void) ...@@ -136,9 +136,9 @@ void test_repo_config__read_with_no_configs_at_all(void)
GIT_OPT_SET_SEARCH_PATH, GIT_CONFIG_LEVEL_XDG, path.ptr)); GIT_OPT_SET_SEARCH_PATH, GIT_CONFIG_LEVEL_XDG, path.ptr));
cl_git_pass(git_repository_open(&repo, "empty_standard_repo")); cl_git_pass(git_repository_open(&repo, "empty_standard_repo"));
git_repository__cvar_cache_clear(repo); git_repository__configmap_lookup_cache_clear(repo);
val = -1; val = -1;
cl_git_pass(git_repository__cvar(&val, repo, GIT_CVAR_ABBREV)); cl_git_pass(git_repository__configmap_lookup(&val, repo, GIT_CONFIGMAP_ABBREV));
cl_assert_equal_i(20, val); cl_assert_equal_i(20, val);
git_repository_free(repo); git_repository_free(repo);
...@@ -151,9 +151,9 @@ void test_repo_config__read_with_no_configs_at_all(void) ...@@ -151,9 +151,9 @@ void test_repo_config__read_with_no_configs_at_all(void)
GIT_OPT_SET_SEARCH_PATH, GIT_CONFIG_LEVEL_GLOBAL, path.ptr)); GIT_OPT_SET_SEARCH_PATH, GIT_CONFIG_LEVEL_GLOBAL, path.ptr));
cl_git_pass(git_repository_open(&repo, "empty_standard_repo")); cl_git_pass(git_repository_open(&repo, "empty_standard_repo"));
git_repository__cvar_cache_clear(repo); git_repository__configmap_lookup_cache_clear(repo);
val = -1; val = -1;
cl_git_pass(git_repository__cvar(&val, repo, GIT_CVAR_ABBREV)); cl_git_pass(git_repository__configmap_lookup(&val, repo, GIT_CONFIGMAP_ABBREV));
cl_assert_equal_i(30, val); cl_assert_equal_i(30, val);
git_repository_free(repo); git_repository_free(repo);
...@@ -162,18 +162,18 @@ void test_repo_config__read_with_no_configs_at_all(void) ...@@ -162,18 +162,18 @@ void test_repo_config__read_with_no_configs_at_all(void)
cl_git_rewritefile("empty_standard_repo/.git/config", "[core]\n\tabbrev = 40\n"); cl_git_rewritefile("empty_standard_repo/.git/config", "[core]\n\tabbrev = 40\n");
cl_git_pass(git_repository_open(&repo, "empty_standard_repo")); cl_git_pass(git_repository_open(&repo, "empty_standard_repo"));
git_repository__cvar_cache_clear(repo); git_repository__configmap_lookup_cache_clear(repo);
val = -1; val = -1;
cl_git_pass(git_repository__cvar(&val, repo, GIT_CVAR_ABBREV)); cl_git_pass(git_repository__configmap_lookup(&val, repo, GIT_CONFIGMAP_ABBREV));
cl_assert_equal_i(40, val); cl_assert_equal_i(40, val);
git_repository_free(repo); git_repository_free(repo);
/* with all configs but delete the files ? */ /* with all configs but delete the files ? */
cl_git_pass(git_repository_open(&repo, "empty_standard_repo")); cl_git_pass(git_repository_open(&repo, "empty_standard_repo"));
git_repository__cvar_cache_clear(repo); git_repository__configmap_lookup_cache_clear(repo);
val = -1; val = -1;
cl_git_pass(git_repository__cvar(&val, repo, GIT_CVAR_ABBREV)); cl_git_pass(git_repository__configmap_lookup(&val, repo, GIT_CONFIGMAP_ABBREV));
cl_assert_equal_i(40, val); cl_assert_equal_i(40, val);
cl_must_pass(p_unlink("empty_standard_repo/.git/config")); cl_must_pass(p_unlink("empty_standard_repo/.git/config"));
...@@ -188,9 +188,9 @@ void test_repo_config__read_with_no_configs_at_all(void) ...@@ -188,9 +188,9 @@ void test_repo_config__read_with_no_configs_at_all(void)
cl_must_pass(p_unlink("alternate/3/.gitconfig")); cl_must_pass(p_unlink("alternate/3/.gitconfig"));
cl_assert(!git_path_isfile("alternate/3/.gitconfig")); cl_assert(!git_path_isfile("alternate/3/.gitconfig"));
git_repository__cvar_cache_clear(repo); git_repository__configmap_lookup_cache_clear(repo);
val = -1; val = -1;
cl_git_pass(git_repository__cvar(&val, repo, GIT_CVAR_ABBREV)); cl_git_pass(git_repository__configmap_lookup(&val, repo, GIT_CONFIGMAP_ABBREV));
cl_assert_equal_i(40, val); cl_assert_equal_i(40, val);
git_repository_free(repo); git_repository_free(repo);
...@@ -200,9 +200,9 @@ void test_repo_config__read_with_no_configs_at_all(void) ...@@ -200,9 +200,9 @@ void test_repo_config__read_with_no_configs_at_all(void)
cl_assert(!git_path_isfile("alternate/3/.gitconfig")); cl_assert(!git_path_isfile("alternate/3/.gitconfig"));
cl_git_pass(git_repository_open(&repo, "empty_standard_repo")); cl_git_pass(git_repository_open(&repo, "empty_standard_repo"));
git_repository__cvar_cache_clear(repo); git_repository__configmap_lookup_cache_clear(repo);
val = -1; val = -1;
cl_git_pass(git_repository__cvar(&val, repo, GIT_CVAR_ABBREV)); cl_git_pass(git_repository__configmap_lookup(&val, repo, GIT_CONFIGMAP_ABBREV));
cl_assert_equal_i(7, val); cl_assert_equal_i(7, val);
git_repository_free(repo); git_repository_free(repo);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment