summaryrefslogtreecommitdiff
path: root/src/commit.c
diff options
context:
space:
mode:
authorVicent Marti <tanoku@gmail.com>2010-05-22 23:21:10 +0200
committerAndreas Ericsson <ae@op5.se>2010-06-02 10:32:06 +0200
commitc5696427b6d53a3f79baad35ea33c556884a410a (patch)
treecb3ab00e68da089aecd496ba4e39b1c706ed7c68 /src/commit.c
parent36b7cdb6a1a2e685c7141406808366d4c4b9f98e (diff)
downloadlibgit2-c5696427b6d53a3f79baad35ea33c556884a410a.tar.gz
Add 'git_revpool_object' and 'git_revpool_table' structures.
All the objects which will will be eventually transversable from a revision pool (commits, trees, etc) now inherit from the 'git_revpool_object' structure which identifies them with their own OID. Furthermore, the 'git_revpool_table' and related functions have been added, which allow for constant time lookup (hash table) of the loaded revpool objects based on their OID. Signed-off-by: Vicent Marti <tanoku@gmail.com> Signed-off-by: Andreas Ericsson <ae@op5.se>
Diffstat (limited to 'src/commit.c')
-rw-r--r--src/commit.c14
1 files changed, 6 insertions, 8 deletions
diff --git a/src/commit.c b/src/commit.c
index b196a807..226eca42 100644
--- a/src/commit.c
+++ b/src/commit.c
@@ -32,7 +32,7 @@
const git_oid *git_commit_id(git_commit *c)
{
- return &c->id;
+ return &c->object.id;
}
void git_commit__mark_uninteresting(git_commit *commit)
@@ -75,10 +75,7 @@ int git_commit_parse_existing(git_commit *commit)
if (commit->parsed)
return 0;
- if (commit->pool == NULL || commit->pool->db == NULL)
- return -1;
-
- if (git_odb_read(&commit_obj, commit->pool->db, &commit->id) < 0)
+ if (git_odb_read(&commit_obj, commit->object.pool->db, &commit->object.id) < 0)
return -1;
if (commit_obj.type != GIT_OBJ_COMMIT)
@@ -110,8 +107,9 @@ git_commit *git_commit_lookup(git_revpool *pool, const git_oid *id)
memset(commit, 0x0, sizeof(git_commit));
- git_oid_cpy(&commit->id, id);
- commit->pool = pool;
+ // Initialize parent object
+ git_oid_cpy(&commit->object.id, id);
+ commit->object.pool = pool;
return commit;
}
@@ -182,7 +180,7 @@ int git_commit__parse_buffer(git_commit *commit, void *data, size_t len)
while (git_commit__parse_oid(&oid, &buffer, buffer_end, "parent ") == 0) {
git_commit *parent;
- if ((parent = git_commit_lookup(commit->pool, &oid)) == NULL)
+ if ((parent = git_commit_lookup(commit->object.pool, &oid)) == NULL)
return -1;
// Inherit uninteresting flag