Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/libgit2.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVicent Marti <tanoku@gmail.com>2011-11-25 11:16:26 +0400
committerVicent Marti <tanoku@gmail.com>2011-11-26 11:37:08 +0400
commit9462c471435b4de74848408bebe41d770dc49a50 (patch)
treeaac5e696d1b3e7b4cba64082b28255e5c4593b66 /src/revwalk.c
parent880b6f0c22153db164ecb3a18c362ba8337365d3 (diff)
repository: Change ownership semantics
The ownership semantics have been changed all over the library to be consistent. There are no more "borrowed" or duplicated references. Main changes: - `git_repository_open2` and `3` have been dropped. - Added setters and getters to hotswap all the repository owned objects: `git_repository_index` `git_repository_set_index` `git_repository_odb` `git_repository_set_odb` `git_repository_config` `git_repository_set_config` `git_repository_workdir` `git_repository_set_workdir` Now working directories/index files/ODBs and so on can be hot-swapped after creating a repository and between operations. - All these objects now have proper ownership semantics with refcounting: they all require freeing after they are no longer needed (the repository always keeps its internal reference). - Repository open and initialization has been updated to keep in mind the configuration files. Bare repositories are now always detected, and a default config file is created on init. - All the tests affected by these changes have been dropped from the old test suite and ported to the new one.
Diffstat (limited to 'src/revwalk.c')
-rw-r--r--src/revwalk.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/revwalk.c b/src/revwalk.c
index 7e31650ff..64775649c 100644
--- a/src/revwalk.c
+++ b/src/revwalk.c
@@ -34,6 +34,7 @@ typedef struct commit_list {
struct git_revwalk {
git_repository *repo;
+ git_odb *odb;
git_hashtable *commits;
@@ -225,7 +226,7 @@ static int commit_parse(git_revwalk *walk, commit_object *commit)
if (commit->parsed)
return GIT_SUCCESS;
- if ((error = git_odb_read(&obj, walk->repo->db, &commit->oid)) < GIT_SUCCESS)
+ if ((error = git_odb_read(&obj, walk->odb, &commit->oid)) < GIT_SUCCESS)
return git__rethrow(error, "Failed to parse commit. Can't read object");
if (obj->raw.type != GIT_OBJ_COMMIT) {
@@ -429,6 +430,7 @@ static int prepare_walk(git_revwalk *walk)
int git_revwalk_new(git_revwalk **revwalk_out, git_repository *repo)
{
+ int error;
git_revwalk *walk;
walk = git__malloc(sizeof(git_revwalk));
@@ -455,6 +457,12 @@ int git_revwalk_new(git_revwalk **revwalk_out, git_repository *repo)
walk->repo = repo;
+ error = git_repository_odb(&walk->odb, repo);
+ if (error < GIT_SUCCESS) {
+ git_revwalk_free(walk);
+ return error;
+ }
+
*revwalk_out = walk;
return GIT_SUCCESS;
}
@@ -469,6 +477,7 @@ void git_revwalk_free(git_revwalk *walk)
return;
git_revwalk_reset(walk);
+ git_odb_free(walk->odb);
/* if the parent has more than PARENTS_PER_COMMIT parents,
* we had to allocate a separate array for those parents.