diff options
author | Russell Belfer <rb@github.com> | 2014-05-13 16:32:27 -0700 |
---|---|---|
committer | Russell Belfer <rb@github.com> | 2014-05-13 16:32:27 -0700 |
commit | 2b52a0bfaedf7571e7ecd706947f5865d513760c (patch) | |
tree | 27faafab276a9023f5357b29f537972c4e385732 /src/attrcache.c | |
parent | a37aa82ea6f952745c883065a86162343e438981 (diff) | |
download | libgit2-2b52a0bfaedf7571e7ecd706947f5865d513760c.tar.gz |
Increase use of config snapshotsrb/coverity-fixes
And decrease extra reload checks of config data.
Diffstat (limited to 'src/attrcache.c')
-rw-r--r-- | src/attrcache.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/src/attrcache.c b/src/attrcache.c index f1bc70467..56c028e60 100644 --- a/src/attrcache.c +++ b/src/attrcache.c @@ -349,14 +349,11 @@ int git_attr_cache__do_init(git_repository *repo) { int ret = 0; git_attr_cache *cache = git_repository_attr_cache(repo); - git_config *cfg; + git_config *cfg = NULL; if (cache) return 0; - if ((ret = git_repository_config__weakptr(&cfg, repo)) < 0) - return ret; - cache = git__calloc(1, sizeof(git_attr_cache)); GITERR_CHECK_ALLOC(cache); @@ -367,6 +364,9 @@ int git_attr_cache__do_init(git_repository *repo) return -1; } + if ((ret = git_repository_config_snapshot(&cfg, repo)) < 0) + goto cancel; + /* cache config settings for attributes and ignores */ ret = attr_cache__lookup_path( &cache->cfg_attr_file, cfg, GIT_ATTR_CONFIG, GIT_ATTR_FILE_XDG); @@ -390,11 +390,14 @@ int git_attr_cache__do_init(git_repository *repo) if (cache) goto cancel; /* raced with another thread, free this but no error */ + git_config_free(cfg); + /* insert default macros */ return git_attr_add_macro(repo, "binary", "-diff -crlf -text"); cancel: attr_cache__free(cache); + git_config_free(cfg); return ret; } |