summaryrefslogtreecommitdiff
path: root/src/commit.c
diff options
context:
space:
mode:
authorVicent Marti <tanoku@gmail.com>2010-07-10 11:50:16 -0700
committerVicent Marti <tanoku@gmail.com>2010-07-15 23:39:22 +0200
commit40721f6b1297f2a48aeb5c9a3ac095767b1153bf (patch)
tree8be856d8f8c8aab89f093583f091979aa2a4b8e3 /src/commit.c
parentb231ef3acdcf396dba5f83f89488be7519da551a (diff)
downloadlibgit2-40721f6b1297f2a48aeb5c9a3ac095767b1153bf.tar.gz
Changed revpool's object table to support arbitrary objects
git_revpool_object now has a type identifier for each object type in a revpool (commits, trees, blobs, etc). Trees can now be stored in the revision pool. git_revpool_tableit now supports filtering objects by their type when iterating through the object table. Signed-off-by: Vicent Marti <tanoku@gmail.com>
Diffstat (limited to 'src/commit.c')
-rw-r--r--src/commit.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/commit.c b/src/commit.c
index 58abd58a..11f76e30 100644
--- a/src/commit.c
+++ b/src/commit.c
@@ -34,6 +34,12 @@
printf("Oid: %s | In degree: %d | Time: %u\n", oid, commit->in_degree, commit->commit_time);\
}
+void git_commit__free(git_commit *commit)
+{
+ git_commit_list_clear(&commit->parents, 0);
+ free(commit);
+}
+
const git_oid *git_commit_id(git_commit *c)
{
return &c->object.id;
@@ -104,7 +110,7 @@ git_commit *git_commit_lookup(git_revpool *pool, const git_oid *id)
if (pool == NULL)
return NULL;
- commit = (git_commit *)git_revpool_table_lookup(pool->commits, id);
+ commit = (git_commit *)git_revpool_table_lookup(pool->objects, id);
if (commit != NULL)
return commit;
@@ -118,8 +124,9 @@ git_commit *git_commit_lookup(git_revpool *pool, const git_oid *id)
/* Initialize parent object */
git_oid_cpy(&commit->object.id, id);
commit->object.pool = pool;
+ commit->object.type = GIT_OBJ_COMMIT;
- git_revpool_table_insert(pool->commits, (git_revpool_object *)commit);
+ git_revpool_table_insert(pool->objects, (git_revpool_object *)commit);
return commit;
}