summaryrefslogtreecommitdiff
path: root/src/config_cache.c
diff options
context:
space:
mode:
authorRussell Belfer <rb@github.com>2014-05-13 16:32:27 -0700
committerRussell Belfer <rb@github.com>2014-05-13 16:32:27 -0700
commit2b52a0bfaedf7571e7ecd706947f5865d513760c (patch)
tree27faafab276a9023f5357b29f537972c4e385732 /src/config_cache.c
parenta37aa82ea6f952745c883065a86162343e438981 (diff)
downloadlibgit2-2b52a0bfaedf7571e7ecd706947f5865d513760c.tar.gz
Increase use of config snapshotsrb/coverity-fixes
And decrease extra reload checks of config data.
Diffstat (limited to 'src/config_cache.c')
-rw-r--r--src/config_cache.c42
1 files changed, 24 insertions, 18 deletions
diff --git a/src/config_cache.c b/src/config_cache.c
index 4bcbf02bf..dca9976f8 100644
--- a/src/config_cache.c
+++ b/src/config_cache.c
@@ -7,11 +7,11 @@
#include "common.h"
#include "fileops.h"
+#include "repository.h"
#include "config.h"
#include "git2/config.h"
#include "vector.h"
#include "filter.h"
-#include "repository.h"
struct map_data {
const char *cvar_name;
@@ -69,32 +69,38 @@ static struct map_data _cvar_maps[] = {
{"core.abbrev", _cvar_map_int, 1, GIT_ABBREV_DEFAULT },
{"core.precomposeunicode", NULL, 0, GIT_PRECOMPOSE_DEFAULT },
{"core.safecrlf", NULL, 0, GIT_SAFE_CRLF_DEFAULT},
+ {"core.logallrefupdates", NULL, 0, GIT_LOGALLREFUPDATES_DEFAULT },
};
+int git_config__cvar(int *out, git_config *config, git_cvar_cached cvar)
+{
+ int error = 0;
+ struct map_data *data = &_cvar_maps[(int)cvar];
+ const git_config_entry *entry;
+
+ git_config__lookup_entry(&entry, config, data->cvar_name, false);
+
+ if (!entry)
+ *out = data->default_value;
+ else if (data->maps)
+ error = git_config_lookup_map_value(
+ out, data->maps, data->map_count, entry->value);
+ else
+ error = git_config_parse_bool(out, entry->value);
+
+ return error;
+}
+
int git_repository__cvar(int *out, git_repository *repo, git_cvar_cached cvar)
{
*out = repo->cvar_cache[(int)cvar];
if (*out == GIT_CVAR_NOT_CACHED) {
- struct map_data *data = &_cvar_maps[(int)cvar];
- git_config *config;
int error;
- const git_config_entry *entry;
-
- if ((error = git_repository_config__weakptr(&config, repo)) < 0)
- return error;
-
- git_config__lookup_entry(&entry, config, data->cvar_name, false);
-
- if (!entry)
- *out = data->default_value;
- else if (data->maps)
- error = git_config_lookup_map_value(
- out, data->maps, data->map_count, entry->value);
- else
- error = git_config_parse_bool(out, entry->value);
+ git_config *config;
- if (error < 0)
+ if ((error = git_repository_config__weakptr(&config, repo)) < 0 ||
+ (error = git_config__cvar(out, config, cvar)) < 0)
return error;
repo->cvar_cache[(int)cvar] = *out;