summaryrefslogtreecommitdiff
path: root/src/repository.c
diff options
context:
space:
mode:
authorCarlos Martín Nieto <cmn@dwim.me>2014-05-07 11:34:32 +0200
committerCarlos Martín Nieto <cmn@dwim.me>2014-05-07 11:34:32 +0200
commitac99d86ba5e2a9d2332b7f82737e1231c621dc43 (patch)
treed9950f8a80d7ac05b64396a608b64a8d4dcd3149 /src/repository.c
parent2280b388c913cbc4eee35ce99c760316206e2703 (diff)
downloadlibgit2-ac99d86ba5e2a9d2332b7f82737e1231c621dc43.tar.gz
repository: introduce a convenience config snapshot methodcmn/config-snapshot
Accessing the repository's config and immediately taking a snapshot of it is a common operation, so let's provide a convenience function for it.
Diffstat (limited to 'src/repository.c')
-rw-r--r--src/repository.c17
1 files changed, 12 insertions, 5 deletions
diff --git a/src/repository.c b/src/repository.c
index c1d98300c..dfddc5966 100644
--- a/src/repository.c
+++ b/src/repository.c
@@ -439,7 +439,7 @@ int git_repository_open_ext(
int error;
git_buf path = GIT_BUF_INIT, parent = GIT_BUF_INIT;
git_repository *repo;
- git_config *repo_config, *config;
+ git_config *config;
if (repo_ptr)
*repo_ptr = NULL;
@@ -454,10 +454,7 @@ int git_repository_open_ext(
repo->path_repository = git_buf_detach(&path);
GITERR_CHECK_ALLOC(repo->path_repository);
- if ((error = git_repository_config__weakptr(&repo_config, repo)) < 0)
- return error;
-
- if ((error = git_config_snapshot(&config, repo_config)) < 0)
+ if ((error = git_repository_config_snapshot(&config, repo)) < 0)
return error;
if ((flags & GIT_REPOSITORY_OPEN_BARE) != 0)
@@ -624,6 +621,16 @@ int git_repository_config(git_config **out, git_repository *repo)
return 0;
}
+int git_repository_config_snapshot(git_config **out, git_repository *repo)
+{
+ git_config *weak;
+
+ if (git_repository_config__weakptr(&weak, repo) < 0)
+ return -1;
+
+ return git_config_snapshot(out, weak);
+}
+
void git_repository_set_config(git_repository *repo, git_config *config)
{
assert(repo && config);