summaryrefslogtreecommitdiff
path: root/src/revwalk.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/revwalk.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/revwalk.c')
-rw-r--r--src/revwalk.c30
1 files changed, 21 insertions, 9 deletions
diff --git a/src/revwalk.c b/src/revwalk.c
index 431007a7f..d23f6863f 100644
--- a/src/revwalk.c
+++ b/src/revwalk.c
@@ -37,7 +37,7 @@ git_revpool *gitrp_alloc(git_odb *db)
memset(walk, 0x0, sizeof(git_revpool));
- walk->commits = git_revpool_table_create(default_table_size);
+ walk->objects = git_revpool_table_create(default_table_size);
walk->db = db;
return walk;
@@ -45,20 +45,29 @@ git_revpool *gitrp_alloc(git_odb *db)
void gitrp_free(git_revpool *walk)
{
- git_commit *commit;
+ git_revpool_object *obj;
git_revpool_tableit it;
git_commit_list_clear(&(walk->iterator), 0);
git_commit_list_clear(&(walk->roots), 0);
- git_revpool_tableit_init(walk->commits, &it);
+ git_revpool_tableit_init(walk->objects, &it);
+
+ while ((obj = git_revpool_tableit_next(&it)) != NULL) {
+ switch (obj->type) {
+
+ case GIT_OBJ_COMMIT:
+ git_commit__free((git_commit *)obj);
+ break;
- while ((commit = (git_commit *)git_revpool_tableit_next(&it)) != NULL) {
- git_commit_list_clear(&commit->parents, 0);
- free(commit);
+
+ default:
+ free(obj);
+ break;
+ }
}
- git_revpool_table_free(walk->commits);
+ git_revpool_table_free(walk->objects);
free(walk);
}
@@ -182,9 +191,12 @@ void gitrp_reset(git_revpool *pool)
git_commit *commit;
git_revpool_tableit it;
- git_revpool_tableit_init(pool->commits, &it);
+ git_revpool_tableit_init(pool->objects, &it);
+
+ while ((commit =
+ (git_commit *)git_revpool_tableit_nextfilter(
+ &it, GIT_OBJ_COMMIT)) != NULL) {
- while ((commit = (git_commit *)git_revpool_tableit_next(&it)) != NULL) {
commit->seen = 0;
commit->topo_delay = 0;
commit->in_degree = 0;