summaryrefslogtreecommitdiff
path: root/src/revwalk.c
diff options
context:
space:
mode:
authorVicent Marti <tanoku@gmail.com>2010-05-23 04:41:31 +0200
committerAndreas Ericsson <ae@op5.se>2010-06-02 10:32:07 +0200
commita7c182c59414cece10c819989bce3f1247f4eacc (patch)
tree54bdf67864a5d9dc16fc548f2748462b3fb63697 /src/revwalk.c
parentd047b47aadf88501238f36f5c17dd0a50dc62087 (diff)
downloadlibgit2-a7c182c59414cece10c819989bce3f1247f4eacc.tar.gz
Add object cache to the revision pool.
Fixed issue when generating pending commits list during iteration. The 'git_commit_lookup' function will now check the pool's cache for commits which have been previously loaded/parsed; there can only be a single 'git_commit' structure for each commit on the same pool. Signed-off-by: Vicent Marti <tanoku@gmail.com> Signed-off-by: Andreas Ericsson <ae@op5.se>
Diffstat (limited to 'src/revwalk.c')
-rw-r--r--src/revwalk.c42
1 files changed, 16 insertions, 26 deletions
diff --git a/src/revwalk.c b/src/revwalk.c
index b24cf42e6..088171c4d 100644
--- a/src/revwalk.c
+++ b/src/revwalk.c
@@ -73,8 +73,6 @@ void gitrp_push(git_revpool *pool, git_commit *commit)
if (commit->uninteresting)
git_commit__mark_uninteresting(commit);
- commit->seen = 1;
-
git_commit_list_append(&pool->roots, commit);
}
@@ -84,38 +82,30 @@ void gitrp_hide(git_revpool *pool, git_commit *commit)
gitrp_push(pool, commit);
}
-void gitrp_prepare_walk(git_revpool *pool)
+void gitrp__enroot(git_revpool *pool, git_commit *commit)
{
- git_commit_node *it;
+ git_commit_node *parents;
- for (it = pool->roots.head; it != NULL; it = it->next)
- {
- git_commit_list_append(&pool->iterator, it->commit);
- }
+ if (commit->seen)
+ return;
- for (it = pool->iterator.head; it != NULL; it = it->next)
- {
- git_commit *commit;
- git_commit_node *parents;
+ if (commit->parsed == 0)
+ git_commit_parse_existing(commit);
- commit = it->commit;
- parents = commit->parents.head;
+ commit->seen = 1;
- while (parents)
- {
- git_commit *parent = parents->commit;
- parents = parents->next;
+ for (parents = commit->parents.head; parents != NULL; parents = parents->next)
+ gitrp__enroot(pool, parents->commit);
- if (parent->seen)
- continue;
+ git_commit_list_append(&pool->iterator, commit);
+}
- if (parent->parsed == 0)
- git_commit_parse_existing(parent);
+void gitrp_prepare_walk(git_revpool *pool)
+{
+ git_commit_node *it;
- parent->seen = 1;
- git_commit_list_append(&pool->iterator, parent);
- }
- }
+ for (it = pool->roots.head; it != NULL; it = it->next)
+ gitrp__enroot(pool, it->commit);
// TODO: topo sort, time sort