From 658022c41affc7d9b5bd9b84b1d75ec909b820c6 Mon Sep 17 00:00:00 2001 From: Patrick Steinhardt Date: Thu, 18 Jul 2019 13:53:41 +0200 Subject: configuration: cvar -> configmap `cvar` is an unhelpful name. Refactor its usage to `configmap` for more clarity. --- include/git2/config.h | 24 +++++++-------- src/checkout.c | 10 +++--- src/config.c | 28 ++++++++--------- src/config.h | 13 ++++---- src/config_cache.c | 76 ++++++++++++++++++++++----------------------- src/crlf.c | 16 +++++----- src/diff_file.c | 4 +-- src/diff_generate.c | 8 ++--- src/diff_print.c | 2 +- src/ignore.c | 6 ++-- src/index.c | 6 ++-- src/iterator.c | 2 +- src/object.c | 2 +- src/odb.c | 2 +- src/pack-objects.c | 2 +- src/path.c | 4 +-- src/refdb_fs.c | 8 ++--- src/refs.c | 2 +- src/repository.c | 12 ++++---- src/repository.h | 78 +++++++++++++++++++++++------------------------ src/stash.c | 2 +- src/submodule.c | 42 ++++++++++++------------- tests/checkout/conflict.c | 2 +- tests/checkout/icase.c | 2 +- tests/diff/workdir.c | 2 +- tests/index/bypath.c | 2 +- tests/repo/config.c | 32 +++++++++---------- 27 files changed, 195 insertions(+), 194 deletions(-) diff --git a/include/git2/config.h b/include/git2/config.h index 0bea323b2..abf5bbbd0 100644 --- a/include/git2/config.h +++ b/include/git2/config.h @@ -92,20 +92,20 @@ typedef struct git_config_iterator git_config_iterator; * Config var type */ typedef enum { - GIT_CVAR_FALSE = 0, - GIT_CVAR_TRUE = 1, - GIT_CVAR_INT32, - GIT_CVAR_STRING -} git_cvar_t; + GIT_CONFIGMAP_FALSE = 0, + GIT_CONFIGMAP_TRUE = 1, + GIT_CONFIGMAP_INT32, + GIT_CONFIGMAP_STRING +} git_configmap_t; /** * Mapping from config variables to values. */ typedef struct { - git_cvar_t cvar_type; + git_configmap_t type; const char *str_match; int map_value; -} git_cvar_map; +} git_configmap; /** * Locate the path to the global configuration file @@ -623,7 +623,7 @@ GIT_EXTERN(int) git_config_foreach_match( * * 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_TRUE, NULL, GIT_AUTO_CRLF_TRUE}, * {GIT_CVAR_STRING, "input", GIT_AUTO_CRLF_INPUT}, @@ -644,7 +644,7 @@ GIT_EXTERN(int) git_config_foreach_match( * @param out place to store the result of the mapping * @param cfg config file to get the variables from * @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` * @return 0 on success, error code otherwise */ @@ -652,20 +652,20 @@ GIT_EXTERN(int) git_config_get_mapped( int *out, const git_config *cfg, const char *name, - const git_cvar_map *maps, + const git_configmap *maps, size_t map_n); /** * Maps a string value to an integer constant * * @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 value value to parse */ GIT_EXTERN(int) git_config_lookup_map_value( int *out, - const git_cvar_map *maps, + const git_configmap *maps, size_t map_n, const char *value); diff --git a/src/checkout.c b/src/checkout.c index 143b5f5d5..730ec626e 100644 --- a/src/checkout.c +++ b/src/checkout.c @@ -1391,7 +1391,7 @@ static bool should_remove_existing(checkout_data *data) { 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; } @@ -2463,12 +2463,12 @@ static int checkout_data_init( data->pfx = git_pathspec_prefix(&data->opts.paths); - if ((error = git_repository__cvar( - &data->can_symlink, repo, GIT_CVAR_SYMLINKS)) < 0) + if ((error = git_repository__configmap_lookup( + &data->can_symlink, repo, GIT_CONFIGMAP_SYMLINKS)) < 0) goto cleanup; - if ((error = git_repository__cvar( - &data->respect_filemode, repo, GIT_CVAR_FILEMODE)) < 0) + if ((error = git_repository__configmap_lookup( + &data->respect_filemode, repo, GIT_CONFIGMAP_FILEMODE)) < 0) goto cleanup; if (!data->opts.baseline && !data->opts.baseline_index) { diff --git a/src/config.c b/src/config.c index 5519fe19c..862476719 100644 --- a/src/config.c +++ b/src/config.c @@ -661,7 +661,7 @@ int git_config_set_string(git_config *cfg, const char *name, const char *value) error = backend->set(backend, name, value); 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; } @@ -777,7 +777,7 @@ int git_config_get_mapped( int *out, const git_config *cfg, const char *name, - const git_cvar_map *maps, + const git_configmap *maps, size_t map_n) { git_config_entry *entry; @@ -1223,7 +1223,7 @@ int git_config_unlock(git_config *cfg, int commit) int git_config_lookup_map_value( int *out, - const git_cvar_map *maps, + const git_configmap *maps, size_t map_n, const char *value) { @@ -1233,27 +1233,27 @@ int git_config_lookup_map_value( goto fail_parse; for (i = 0; i < map_n; ++i) { - const git_cvar_map *m = maps + i; + const git_configmap *m = maps + i; - switch (m->cvar_type) { - case GIT_CVAR_FALSE: - case GIT_CVAR_TRUE: { + switch (m->type) { + case GIT_CONFIGMAP_FALSE: + case GIT_CONFIGMAP_TRUE: { int bool_val; if (git__parse_bool(&bool_val, value) == 0 && - bool_val == (int)m->cvar_type) { + bool_val == (int)m->type) { *out = m->map_value; return 0; } break; } - case GIT_CVAR_INT32: + case GIT_CONFIGMAP_INT32: if (git_config_parse_int32(out, value) == 0) return 0; break; - case GIT_CVAR_STRING: + case GIT_CONFIGMAP_STRING: if (strcasecmp(value, m->str_match) == 0) { *out = m->map_value; return 0; @@ -1267,18 +1267,18 @@ fail_parse: return -1; } -int git_config_lookup_map_enum(git_cvar_t *type_out, const char **str_out, - const git_cvar_map *maps, size_t map_n, int enum_val) +int git_config_lookup_map_enum(git_configmap_t *type_out, const char **str_out, + const git_configmap *maps, size_t map_n, int enum_val) { size_t 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) continue; - *type_out = m->cvar_type; + *type_out = m->type; *str_out = m->str_match; return 0; } diff --git a/src/config.h b/src/config.h index f5855113f..a1d8f7d23 100644 --- a/src/config.h +++ b/src/config.h @@ -66,18 +66,19 @@ extern int git_config__get_bool_force( extern int git_config__get_int_force( const git_config *cfg, const char *key, int fallback_value); -/* API for repository cvar-style lookups from config - not cached, but - * uses cvar value maps and fallbacks +/* API for repository configmap-style lookups from config - not cached, but + * uses configmap value maps and fallbacks */ -extern int git_config__cvar( - int *out, git_config *config, git_cvar_cached cvar); +extern int git_config__configmap_lookup( + int *out, git_config *config, git_configmap_item item); /** * 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. */ -int git_config_lookup_map_enum(git_cvar_t *type_out, const char **str_out, - const git_cvar_map *maps, size_t map_n, int enum_val); +int git_config_lookup_map_enum(git_configmap_t *type_out, + const char **str_out, const git_configmap *maps, + size_t map_n, int enum_val); /** * Unlock the backend with the highest priority diff --git a/src/config_cache.c b/src/config_cache.c index 2530217c9..dbc463bcf 100644 --- a/src/config_cache.c +++ b/src/config_cache.c @@ -15,8 +15,8 @@ #include "filter.h" struct map_data { - const char *cvar_name; - git_cvar_map *maps; + const char *name; + git_configmap *maps; size_t map_count; int default_value; }; @@ -29,11 +29,11 @@ struct map_data { * value is native. See gitattributes(5) for more information on * end-of-line conversion. */ -static git_cvar_map _cvar_map_eol[] = { - {GIT_CVAR_FALSE, NULL, GIT_EOL_UNSET}, - {GIT_CVAR_STRING, "lf", GIT_EOL_LF}, - {GIT_CVAR_STRING, "crlf", GIT_EOL_CRLF}, - {GIT_CVAR_STRING, "native", GIT_EOL_NATIVE} +static git_configmap _configmap_eol[] = { + {GIT_CONFIGMAP_FALSE, NULL, GIT_EOL_UNSET}, + {GIT_CONFIGMAP_STRING, "lf", GIT_EOL_LF}, + {GIT_CONFIGMAP_STRING, "crlf", GIT_EOL_CRLF}, + {GIT_CONFIGMAP_STRING, "native", GIT_EOL_NATIVE} }; /* @@ -46,55 +46,55 @@ static git_cvar_map _cvar_map_eol[] = { * does not have normalized line endings. This variable can be set to input, * in which case no output conversion is performed. */ -static git_cvar_map _cvar_map_autocrlf[] = { - {GIT_CVAR_FALSE, NULL, GIT_AUTO_CRLF_FALSE}, - {GIT_CVAR_TRUE, NULL, GIT_AUTO_CRLF_TRUE}, - {GIT_CVAR_STRING, "input", GIT_AUTO_CRLF_INPUT} +static git_configmap _configmap_autocrlf[] = { + {GIT_CONFIGMAP_FALSE, NULL, GIT_AUTO_CRLF_FALSE}, + {GIT_CONFIGMAP_TRUE, NULL, GIT_AUTO_CRLF_TRUE}, + {GIT_CONFIGMAP_STRING, "input", GIT_AUTO_CRLF_INPUT} }; -static git_cvar_map _cvar_map_safecrlf[] = { - {GIT_CVAR_FALSE, NULL, GIT_SAFE_CRLF_FALSE}, - {GIT_CVAR_TRUE, NULL, GIT_SAFE_CRLF_FAIL}, - {GIT_CVAR_STRING, "warn", GIT_SAFE_CRLF_WARN} +static git_configmap _configmap_safecrlf[] = { + {GIT_CONFIGMAP_FALSE, NULL, GIT_SAFE_CRLF_FALSE}, + {GIT_CONFIGMAP_TRUE, NULL, GIT_SAFE_CRLF_FAIL}, + {GIT_CONFIGMAP_STRING, "warn", GIT_SAFE_CRLF_WARN} }; -static git_cvar_map _cvar_map_logallrefupdates[] = { - {GIT_CVAR_FALSE, NULL, GIT_LOGALLREFUPDATES_FALSE}, - {GIT_CVAR_TRUE, NULL, GIT_LOGALLREFUPDATES_TRUE}, - {GIT_CVAR_STRING, "always", GIT_LOGALLREFUPDATES_ALWAYS}, +static git_configmap _configmap_logallrefupdates[] = { + {GIT_CONFIGMAP_FALSE, NULL, GIT_LOGALLREFUPDATES_FALSE}, + {GIT_CONFIGMAP_TRUE, NULL, GIT_LOGALLREFUPDATES_TRUE}, + {GIT_CONFIGMAP_STRING, "always", GIT_LOGALLREFUPDATES_ALWAYS}, }; /* * Generic map for integer values */ -static git_cvar_map _cvar_map_int[] = { - {GIT_CVAR_INT32, NULL, 0}, +static git_configmap _configmap_int[] = { + {GIT_CONFIGMAP_INT32, NULL, 0}, }; -static struct map_data _cvar_maps[] = { - {"core.autocrlf", _cvar_map_autocrlf, ARRAY_SIZE(_cvar_map_autocrlf), GIT_AUTO_CRLF_DEFAULT}, - {"core.eol", _cvar_map_eol, ARRAY_SIZE(_cvar_map_eol), GIT_EOL_DEFAULT}, +static struct map_data _configmaps[] = { + {"core.autocrlf", _configmap_autocrlf, ARRAY_SIZE(_configmap_autocrlf), GIT_AUTO_CRLF_DEFAULT}, + {"core.eol", _configmap_eol, ARRAY_SIZE(_configmap_eol), GIT_EOL_DEFAULT}, {"core.symlinks", NULL, 0, GIT_SYMLINKS_DEFAULT }, {"core.ignorecase", NULL, 0, GIT_IGNORECASE_DEFAULT }, {"core.filemode", NULL, 0, GIT_FILEMODE_DEFAULT }, {"core.ignorestat", NULL, 0, GIT_IGNORESTAT_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.safecrlf", _cvar_map_safecrlf, ARRAY_SIZE(_cvar_map_safecrlf), GIT_SAFE_CRLF_DEFAULT}, - {"core.logallrefupdates", _cvar_map_logallrefupdates, ARRAY_SIZE(_cvar_map_logallrefupdates), GIT_LOGALLREFUPDATES_DEFAULT}, + {"core.safecrlf", _configmap_safecrlf, ARRAY_SIZE(_configmap_safecrlf), GIT_SAFE_CRLF_DEFAULT}, + {"core.logallrefupdates", _configmap_logallrefupdates, ARRAY_SIZE(_configmap_logallrefupdates), GIT_LOGALLREFUPDATES_DEFAULT}, {"core.protecthfs", NULL, 0, GIT_PROTECTHFS_DEFAULT }, {"core.protectntfs", NULL, 0, GIT_PROTECTNTFS_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; - struct map_data *data = &_cvar_maps[(int)cvar]; + struct map_data *data = &_configmaps[(int)item]; 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; if (!entry) @@ -109,29 +109,29 @@ int git_config__cvar(int *out, git_config *config, git_cvar_cached cvar) 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; git_config *config; 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; - repo->cvar_cache[(int)cvar] = *out; + repo->configmap_cache[(int)item] = *out; } return 0; } -void git_repository__cvar_cache_clear(git_repository *repo) +void git_repository__configmap_lookup_cache_clear(git_repository *repo) { int i; - for (i = 0; i < GIT_CVAR_CACHE_MAX; ++i) - repo->cvar_cache[i] = GIT_CVAR_NOT_CACHED; + for (i = 0; i < GIT_CONFIGMAP_CACHE_MAX; ++i) + repo->configmap_cache[i] = GIT_CONFIGMAP_NOT_CACHED; } diff --git a/src/crlf.c b/src/crlf.c index 6e8eaa960..22989c16e 100644 --- a/src/crlf.c +++ b/src/crlf.c @@ -58,7 +58,7 @@ static git_crlf_t check_crlf(const char *value) 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)) ; @@ -127,7 +127,7 @@ static int text_eol_is_crlf(struct crlf_attrs *ca) 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) { case GIT_CRLF_BINARY: @@ -293,12 +293,12 @@ static int convert_attrs( memset(ca, 0, sizeof(struct crlf_attrs)); - if ((error = git_repository__cvar(&ca->auto_crlf, - git_filter_source_repo(src), GIT_CVAR_AUTO_CRLF)) < 0 || - (error = git_repository__cvar(&ca->safe_crlf, - git_filter_source_repo(src), GIT_CVAR_SAFE_CRLF)) < 0 || - (error = git_repository__cvar(&ca->core_eol, - git_filter_source_repo(src), GIT_CVAR_EOL)) < 0) + if ((error = git_repository__configmap_lookup(&ca->auto_crlf, + git_filter_source_repo(src), GIT_CONFIGMAP_AUTO_CRLF)) < 0 || + (error = git_repository__configmap_lookup(&ca->safe_crlf, + git_filter_source_repo(src), GIT_CONFIGMAP_SAFE_CRLF)) < 0 || + (error = git_repository__configmap_lookup(&ca->core_eol, + git_filter_source_repo(src), GIT_CONFIGMAP_EOL)) < 0) return error; /* downgrade FAIL to WARN if ALLOW_UNSAFE option is used */ diff --git a/src/diff_file.c b/src/diff_file.c index d507c755f..48e95eb00 100644 --- a/src/diff_file.c +++ b/src/diff_file.c @@ -290,8 +290,8 @@ static int diff_file_content_load_workdir_symlink( ssize_t alloc_len, read_len; int symlink_supported, error; - if ((error = git_repository__cvar( - &symlink_supported, fc->repo, GIT_CVAR_SYMLINKS)) < 0) + if ((error = git_repository__configmap_lookup( + &symlink_supported, fc->repo, GIT_CONFIGMAP_SYMLINKS)) < 0) return -1; if (!symlink_supported) diff --git a/src/diff_generate.c b/src/diff_generate.c index 001cefd54..dad3c0c41 100644 --- a/src/diff_generate.c +++ b/src/diff_generate.c @@ -472,17 +472,17 @@ static int diff_generated_apply_options( if ((val = git_repository_config_snapshot(&cfg, repo)) < 0) 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; - 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; 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; - 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; /* Don't set GIT_DIFFCAPS_USE_DEV - compile time option in core git */ diff --git a/src/diff_print.c b/src/diff_print.c index e1a25a959..664336e21 100644 --- a/src/diff_print.c +++ b/src/diff_print.c @@ -48,7 +48,7 @@ static int diff_print_info_init__common( if (!pi->id_strlen) { if (!repo) 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; } diff --git a/src/ignore.c b/src/ignore.c index 0fdadfb13..825ab3cf9 100644 --- a/src/ignore.c +++ b/src/ignore.c @@ -172,7 +172,7 @@ static int parse_ignore_file( 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(); /* if subdir file path, convert context for file paths */ @@ -298,8 +298,8 @@ int git_ignore__for_path( ignores->repo = repo; /* Read the ignore_case flag */ - if ((error = git_repository__cvar( - &ignores->ignore_case, repo, GIT_CVAR_IGNORECASE)) < 0) + if ((error = git_repository__configmap_lookup( + &ignores->ignore_case, repo, GIT_CONFIGMAP_IGNORECASE)) < 0) goto cleanup; if ((error = git_attr_cache__init(repo)) < 0) diff --git a/src/index.c b/src/index.c index 0c90173bc..dc3d8f31e 100644 --- a/src/index.c +++ b/src/index.c @@ -570,11 +570,11 @@ int git_index_set_caps(git_index *index, int caps) return create_index_error( -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); - if (!git_repository__cvar(&val, repo, GIT_CVAR_FILEMODE)) + if (!git_repository__configmap_lookup(&val, repo, GIT_CONFIGMAP_FILEMODE)) 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); } else { diff --git a/src/iterator.c b/src/iterator.c index d00b8aa62..3cfbd1f96 100644 --- a/src/iterator.c +++ b/src/iterator.c @@ -145,7 +145,7 @@ static int iterator_init_common( (iter->flags & GIT_ITERATOR_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(); else if (precompose) iter->flags |= GIT_ITERATOR_PRECOMPOSE_UNICODE; diff --git a/src/object.c b/src/object.c index 17b9794c9..c28629c48 100644 --- a/src/object.c +++ b/src/object.c @@ -496,7 +496,7 @@ int git_object_short_id(git_buf *out, const git_object *obj) git_buf_sanitize(out); 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; if ((error = git_repository_odb(&odb, repo)) < 0) diff --git a/src/odb.c b/src/odb.c index e04cf02ea..24befad18 100644 --- a/src/odb.c +++ b/src/odb.c @@ -666,7 +666,7 @@ int git_odb__set_caps(git_odb *odb, int caps) 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; } diff --git a/src/pack-objects.c b/src/pack-objects.c index 49ded4a2e..bdd5171a8 100644 --- a/src/pack-objects.c +++ b/src/pack-objects.c @@ -1397,7 +1397,7 @@ int git_packbuilder_write( &indexer, path, mode, pb->odb, &opts) < 0) 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); ctx.indexer = indexer; diff --git a/src/path.c b/src/path.c index b1a92ae44..df6b6233b 100644 --- a/src/path.c +++ b/src/path.c @@ -1832,12 +1832,12 @@ GIT_INLINE(unsigned int) dotgit_flags( #endif 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) flags |= GIT_PATH_REJECT_DOT_GIT_HFS; 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) flags |= GIT_PATH_REJECT_DOT_GIT_NTFS; diff --git a/src/refdb_fs.c b/src/refdb_fs.c index e5ee392fc..09ec7192f 100644 --- a/src/refdb_fs.c +++ b/src/refdb_fs.c @@ -1104,7 +1104,7 @@ static int should_write_reflog(int *write, git_repository *repo, const char *nam { 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) return error; @@ -2114,15 +2114,15 @@ int git_refdb_backend_fs( 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->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->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) backend->fsync = 1; backend->iterator_flags |= GIT_ITERATOR_DESCEND_SYMLINKS; diff --git a/src/refs.c b/src/refs.c index dce9e7954..fd407b34b 100644 --- a/src/refs.c +++ b/src/refs.c @@ -188,7 +188,7 @@ static int reference_normalize_for_repo( int precompose; 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) flags |= GIT_REFERENCE_FORMAT__PRECOMPOSE_UNICODE; diff --git a/src/repository.c b/src/repository.c index 71386d65f..d8eb4ba07 100644 --- a/src/repository.c +++ b/src/repository.c @@ -122,7 +122,7 @@ static void set_config(git_repository *repo, git_config *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) @@ -239,8 +239,8 @@ static git_repository *repository_alloc(void) if (!repo->reserved_names.ptr) goto on_error; - /* set all the entries in the cvar cache to `unset` */ - git_repository__cvar_cache_clear(repo); + /* set all the entries in the configmap cache to `unset` */ + git_repository__configmap_lookup_cache_clear(repo); return repo; @@ -1287,8 +1287,8 @@ bool git_repository__reserved_names( int (*prefixcmp)(const char *, const char *); int error, ignorecase; - error = git_repository__cvar( - &ignorecase, repo, GIT_CVAR_IGNORECASE); + error = git_repository__configmap_lookup( + &ignorecase, repo, GIT_CONFIGMAP_IGNORECASE); prefixcmp = (error || ignorecase) ? git__prefixcmp_icase : git__prefixcmp; @@ -1660,7 +1660,7 @@ int git_repository_reinit_filesystem(git_repository *repo, int recurse) git_config_free(config); git_buf_dispose(&path); - git_repository__cvar_cache_clear(repo); + git_repository__configmap_lookup_cache_clear(repo); if (!repo->is_bare && recurse) (void)git_submodule_foreach(repo, repo_reinit_submodule_fs, NULL); diff --git a/src/repository.h b/src/repository.h index 450a8bf04..1e02bcc7a 100644 --- a/src/repository.h +++ b/src/repository.h @@ -37,34 +37,34 @@ extern bool git_repository__fsync_gitdir; /** Cvar cache identifiers */ typedef enum { - GIT_CVAR_AUTO_CRLF = 0, /* core.autocrlf */ - GIT_CVAR_EOL, /* core.eol */ - GIT_CVAR_SYMLINKS, /* core.symlinks */ - GIT_CVAR_IGNORECASE, /* core.ignorecase */ - GIT_CVAR_FILEMODE, /* core.filemode */ - GIT_CVAR_IGNORESTAT, /* core.ignorestat */ - GIT_CVAR_TRUSTCTIME, /* core.trustctime */ - GIT_CVAR_ABBREV, /* core.abbrev */ - GIT_CVAR_PRECOMPOSE, /* core.precomposeunicode */ - GIT_CVAR_SAFE_CRLF, /* core.safecrlf */ - GIT_CVAR_LOGALLREFUPDATES, /* core.logallrefupdates */ - GIT_CVAR_PROTECTHFS, /* core.protectHFS */ - GIT_CVAR_PROTECTNTFS, /* core.protectNTFS */ - GIT_CVAR_FSYNCOBJECTFILES, /* core.fsyncObjectFiles */ - GIT_CVAR_CACHE_MAX -} git_cvar_cached; + GIT_CONFIGMAP_AUTO_CRLF = 0, /* core.autocrlf */ + GIT_CONFIGMAP_EOL, /* core.eol */ + GIT_CONFIGMAP_SYMLINKS, /* core.symlinks */ + GIT_CONFIGMAP_IGNORECASE, /* core.ignorecase */ + GIT_CONFIGMAP_FILEMODE, /* core.filemode */ + GIT_CONFIGMAP_IGNORESTAT, /* core.ignorestat */ + GIT_CONFIGMAP_TRUSTCTIME, /* core.trustctime */ + GIT_CONFIGMAP_ABBREV, /* core.abbrev */ + GIT_CONFIGMAP_PRECOMPOSE, /* core.precomposeunicode */ + GIT_CONFIGMAP_SAFE_CRLF, /* core.safecrlf */ + GIT_CONFIGMAP_LOGALLREFUPDATES, /* core.logallrefupdates */ + GIT_CONFIGMAP_PROTECTHFS, /* core.protectHFS */ + GIT_CONFIGMAP_PROTECTNTFS, /* core.protectNTFS */ + GIT_CONFIGMAP_FSYNCOBJECTFILES, /* core.fsyncObjectFiles */ + GIT_CONFIGMAP_CACHE_MAX +} git_configmap_item; /** - * CVAR value enumerations + * Configuration map value enumerations * - * These are the values that are actually stored in the cvar cache, instead - * of their string equivalents. These values are internal and symbolic; - * make sure that none of them is set to `-1`, since that is the unique - * identifier for "not cached" + * These are the values that are actually stored in the configmap cache, + * instead of their string equivalents. These values are internal and + * symbolic; make sure that none of them is set to `-1`, since that is + * the unique identifier for "not cached" */ typedef enum { /* 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' */ GIT_SAFE_CRLF_FALSE = 0, @@ -89,34 +89,34 @@ typedef enum { GIT_EOL_DEFAULT = GIT_EOL_NATIVE, /* core.symlinks: bool */ - GIT_SYMLINKS_DEFAULT = GIT_CVAR_TRUE, + GIT_SYMLINKS_DEFAULT = GIT_CONFIGMAP_TRUE, /* core.ignorecase */ - GIT_IGNORECASE_DEFAULT = GIT_CVAR_FALSE, + GIT_IGNORECASE_DEFAULT = GIT_CONFIGMAP_FALSE, /* core.filemode */ - GIT_FILEMODE_DEFAULT = GIT_CVAR_TRUE, + GIT_FILEMODE_DEFAULT = GIT_CONFIGMAP_TRUE, /* core.ignorestat */ - GIT_IGNORESTAT_DEFAULT = GIT_CVAR_FALSE, + GIT_IGNORESTAT_DEFAULT = GIT_CONFIGMAP_FALSE, /* core.trustctime */ - GIT_TRUSTCTIME_DEFAULT = GIT_CVAR_TRUE, + GIT_TRUSTCTIME_DEFAULT = GIT_CONFIGMAP_TRUE, /* core.abbrev */ GIT_ABBREV_DEFAULT = 7, /* core.precomposeunicode */ - GIT_PRECOMPOSE_DEFAULT = GIT_CVAR_FALSE, + GIT_PRECOMPOSE_DEFAULT = GIT_CONFIGMAP_FALSE, /* core.safecrlf */ - GIT_SAFE_CRLF_DEFAULT = GIT_CVAR_FALSE, + GIT_SAFE_CRLF_DEFAULT = GIT_CONFIGMAP_FALSE, /* core.logallrefupdates */ - GIT_LOGALLREFUPDATES_FALSE = GIT_CVAR_FALSE, - GIT_LOGALLREFUPDATES_TRUE = GIT_CVAR_TRUE, + GIT_LOGALLREFUPDATES_FALSE = GIT_CONFIGMAP_FALSE, + GIT_LOGALLREFUPDATES_TRUE = GIT_CONFIGMAP_TRUE, GIT_LOGALLREFUPDATES_UNSET = 2, GIT_LOGALLREFUPDATES_ALWAYS = 3, GIT_LOGALLREFUPDATES_DEFAULT = GIT_LOGALLREFUPDATES_UNSET, /* core.protectHFS */ - GIT_PROTECTHFS_DEFAULT = GIT_CVAR_FALSE, + GIT_PROTECTHFS_DEFAULT = GIT_CONFIGMAP_FALSE, /* core.protectNTFS */ - GIT_PROTECTNTFS_DEFAULT = GIT_CVAR_FALSE, + GIT_PROTECTNTFS_DEFAULT = GIT_CONFIGMAP_FALSE, /* core.fsyncObjectFiles */ - GIT_FSYNCOBJECTFILES_DEFAULT = GIT_CVAR_FALSE, -} git_cvar_value; + GIT_FSYNCOBJECTFILES_DEFAULT = GIT_CONFIGMAP_FALSE, +} git_configmap_value; /* internal repository init flags */ enum { @@ -154,7 +154,7 @@ struct git_repository { 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; }; @@ -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); /* - * CVAR cache + * Configuration map cache * * Efficient access to the most used config variables of a repository. * The cache is cleared every time the config backend is replaced. */ -int git_repository__cvar(int *out, git_repository *repo, git_cvar_cached cvar); -void git_repository__cvar_cache_clear(git_repository *repo); +int git_repository__configmap_lookup(int *out, git_repository *repo, git_configmap_item item); +void git_repository__configmap_lookup_cache_clear(git_repository *repo); GIT_INLINE(int) git_repository__ensure_not_bare( git_repository *repo, diff --git a/src/stash.c b/src/stash.c index c46830bcf..2d61e6828 100644 --- a/src/stash.c +++ b/src/stash.c @@ -412,7 +412,7 @@ static int commit_worktree( goto cleanup; 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; git_index__set_ignore_case(i_index, ignorecase); diff --git a/src/submodule.c b/src/submodule.c index cb11a7cad..cf89fc99b 100644 --- a/src/submodule.c +++ b/src/submodule.c @@ -26,28 +26,28 @@ #define GIT_MODULES_FILE ".gitmodules" -static git_cvar_map _sm_update_map[] = { - {GIT_CVAR_STRING, "checkout", GIT_SUBMODULE_UPDATE_CHECKOUT}, - {GIT_CVAR_STRING, "rebase", GIT_SUBMODULE_UPDATE_REBASE}, - {GIT_CVAR_STRING, "merge", GIT_SUBMODULE_UPDATE_MERGE}, - {GIT_CVAR_STRING, "none", GIT_SUBMODULE_UPDATE_NONE}, - {GIT_CVAR_FALSE, NULL, GIT_SUBMODULE_UPDATE_NONE}, - {GIT_CVAR_TRUE, NULL, GIT_SUBMODULE_UPDATE_CHECKOUT}, +static git_configmap _sm_update_map[] = { + {GIT_CONFIGMAP_STRING, "checkout", GIT_SUBMODULE_UPDATE_CHECKOUT}, + {GIT_CONFIGMAP_STRING, "rebase", GIT_SUBMODULE_UPDATE_REBASE}, + {GIT_CONFIGMAP_STRING, "merge", GIT_SUBMODULE_UPDATE_MERGE}, + {GIT_CONFIGMAP_STRING, "none", GIT_SUBMODULE_UPDATE_NONE}, + {GIT_CONFIGMAP_FALSE, NULL, GIT_SUBMODULE_UPDATE_NONE}, + {GIT_CONFIGMAP_TRUE, NULL, GIT_SUBMODULE_UPDATE_CHECKOUT}, }; -static git_cvar_map _sm_ignore_map[] = { - {GIT_CVAR_STRING, "none", GIT_SUBMODULE_IGNORE_NONE}, - {GIT_CVAR_STRING, "untracked", GIT_SUBMODULE_IGNORE_UNTRACKED}, - {GIT_CVAR_STRING, "dirty", GIT_SUBMODULE_IGNORE_DIRTY}, - {GIT_CVAR_STRING, "all", GIT_SUBMODULE_IGNORE_ALL}, - {GIT_CVAR_FALSE, NULL, GIT_SUBMODULE_IGNORE_NONE}, - {GIT_CVAR_TRUE, NULL, GIT_SUBMODULE_IGNORE_ALL}, +static git_configmap _sm_ignore_map[] = { + {GIT_CONFIGMAP_STRING, "none", GIT_SUBMODULE_IGNORE_NONE}, + {GIT_CONFIGMAP_STRING, "untracked", GIT_SUBMODULE_IGNORE_UNTRACKED}, + {GIT_CONFIGMAP_STRING, "dirty", GIT_SUBMODULE_IGNORE_DIRTY}, + {GIT_CONFIGMAP_STRING, "all", GIT_SUBMODULE_IGNORE_ALL}, + {GIT_CONFIGMAP_FALSE, NULL, GIT_SUBMODULE_IGNORE_NONE}, + {GIT_CONFIGMAP_TRUE, NULL, GIT_SUBMODULE_IGNORE_ALL}, }; -static git_cvar_map _sm_recurse_map[] = { - {GIT_CVAR_STRING, "on-demand", GIT_SUBMODULE_RECURSE_ONDEMAND}, - {GIT_CVAR_FALSE, NULL, GIT_SUBMODULE_RECURSE_NO}, - {GIT_CVAR_TRUE, NULL, GIT_SUBMODULE_RECURSE_YES}, +static git_configmap _sm_recurse_map[] = { + {GIT_CONFIGMAP_STRING, "on-demand", GIT_SUBMODULE_RECURSE_ONDEMAND}, + {GIT_CONFIGMAP_FALSE, NULL, GIT_SUBMODULE_RECURSE_NO}, + {GIT_CONFIGMAP_TRUE, NULL, GIT_SUBMODULE_RECURSE_YES}, }; enum { @@ -989,9 +989,9 @@ cleanup: 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; 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 return -1; } - if (type == GIT_CVAR_TRUE) + if (type == GIT_CONFIGMAP_TRUE) val = "true"; return write_var(repo, name, var, val); diff --git a/tests/checkout/conflict.c b/tests/checkout/conflict.c index 914b3c2de..3ad830f28 100644 --- a/tests/checkout/conflict.c +++ b/tests/checkout/conflict.c @@ -192,7 +192,7 @@ static void ensure_workdir_link( { 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) { ensure_workdir_contents(path, target); diff --git a/tests/checkout/icase.c b/tests/checkout/icase.c index b444878c3..077d24cd3 100644 --- a/tests/checkout/icase.c +++ b/tests/checkout/icase.c @@ -96,7 +96,7 @@ static int symlink_or_fake(git_repository *repo, const char *a, const char *b) { 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) return p_symlink(a, b); diff --git a/tests/diff/workdir.c b/tests/diff/workdir.c index 7a045b4fe..8b0445214 100644 --- a/tests/diff/workdir.c +++ b/tests/diff/workdir.c @@ -2112,7 +2112,7 @@ void test_diff_workdir__symlink_changed_on_non_symlink_platform(void) 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) cl_skip(); diff --git a/tests/index/bypath.c b/tests/index/bypath.c index f911ffb51..21d3d3ed0 100644 --- a/tests/index/bypath.c +++ b/tests/index/bypath.c @@ -338,7 +338,7 @@ void test_index_bypath__add_honors_symlink(void) git_index_entry new_entry; 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) cl_skip(); diff --git a/tests/repo/config.c b/tests/repo/config.c index b92d84202..a397ee525 100644 --- a/tests/repo/config.c +++ b/tests/repo/config.c @@ -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_git_pass(git_repository_open(&repo, "empty_standard_repo")); - git_repository__cvar_cache_clear(repo); + git_repository__configmap_lookup_cache_clear(repo); 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); git_repository_free(repo); @@ -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)); 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; - 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); git_repository_free(repo); @@ -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)); 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; - 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); git_repository_free(repo); @@ -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)); 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; - 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); git_repository_free(repo); @@ -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_pass(git_repository_open(&repo, "empty_standard_repo")); - git_repository__cvar_cache_clear(repo); + git_repository__configmap_lookup_cache_clear(repo); 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); git_repository_free(repo); /* with all configs but delete the files ? */ 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; - 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_must_pass(p_unlink("empty_standard_repo/.git/config")); @@ -188,9 +188,9 @@ void test_repo_config__read_with_no_configs_at_all(void) cl_must_pass(p_unlink("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; - 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); git_repository_free(repo); @@ -200,9 +200,9 @@ void test_repo_config__read_with_no_configs_at_all(void) cl_assert(!git_path_isfile("alternate/3/.gitconfig")); 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; - 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); git_repository_free(repo); -- cgit v1.2.1