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/repository.c | |
parent | a37aa82ea6f952745c883065a86162343e438981 (diff) | |
download | libgit2-rb/coverity-fixes.tar.gz |
Increase use of config snapshotsrb/coverity-fixes
And decrease extra reload checks of config data.
Diffstat (limited to 'src/repository.c')
-rw-r--r-- | src/repository.c | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/src/repository.c b/src/repository.c index 7d055e28e..b0db5484a 100644 --- a/src/repository.c +++ b/src/repository.c @@ -443,7 +443,6 @@ int git_repository_open_ext( int error; git_buf path = GIT_BUF_INIT, parent = GIT_BUF_INIT; git_repository *repo; - git_config *config; if (repo_ptr) *repo_ptr = NULL; @@ -458,23 +457,24 @@ int git_repository_open_ext( repo->path_repository = git_buf_detach(&path); GITERR_CHECK_ALLOC(repo->path_repository); - if ((error = git_repository_config_snapshot(&config, repo)) < 0) - return error; - if ((flags & GIT_REPOSITORY_OPEN_BARE) != 0) repo->is_bare = 1; - else if ((error = load_config_data(repo, config)) < 0 || - (error = load_workdir(repo, config, &parent)) < 0) - { + else { + git_config *config = NULL; + + if ((error = git_repository_config_snapshot(&config, repo)) < 0 || + (error = load_config_data(repo, config)) < 0 || + (error = load_workdir(repo, config, &parent)) < 0) + git_repository_free(repo); + git_config_free(config); - git_repository_free(repo); - return error; } - git_config_free(config); + if (!error) + *repo_ptr = repo; git_buf_free(&parent); - *repo_ptr = repo; - return 0; + + return error; } int git_repository_open(git_repository **repo_out, const char *path) |