diff options
author | Vicent Marti <tanoku@gmail.com> | 2010-05-18 20:55:19 +0200 |
---|---|---|
committer | Andreas Ericsson <ae@op5.se> | 2010-06-02 10:32:06 +0200 |
commit | 08d5d00056a7237bf6c60f85a6e72b7549cf9133 (patch) | |
tree | b47ba8387c1d7209d4976af9c3928f6ce93ed545 /src/commit.c | |
parent | 42281e007e15713713b2ff4324d60360332e194e (diff) | |
download | libgit2-08d5d00056a7237bf6c60f85a6e72b7549cf9133.tar.gz |
Add commit parents to parsed commits and commit lists to the revpool.
Basic support for iterating the revpool.
The following functions of the revwalk API have been partially
implemented:
void gitrp_reset(git_revpool *pool);
void gitrp_push(git_revpool *pool, git_commit *commit);
void gitrp_prepare_walk(git_revpool *pool);
git_commit *gitrp_next(git_revpool *pool);
Parsed commits' parents are now also parsed and stored in a
"git_commit_list" structure (linked list).
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.c | 45 |
1 files changed, 44 insertions, 1 deletions
diff --git a/src/commit.c b/src/commit.c index 1b30c5d6f..8844825b8 100644 --- a/src/commit.c +++ b/src/commit.c @@ -35,6 +35,22 @@ const git_oid *git_commit_id(git_commit *c) return &c->id; } +void git_commit_mark_uninteresting(git_commit *commit) +{ + git_commit_list *parents = commit->parents; + + commit->flags |= GIT_COMMIT_HIDE; + + /* + * FIXME: mark recursively the parents' parents? + * They are most likely not parsed yet... + */ + while (parents) { + parents->commit->flags |= GIT_COMMIT_HIDE; + parents = parents->next; + } +} + git_commit *git_commit_lookup(git_revpool *pool, const git_oid *id) { git_obj commit_obj; @@ -141,7 +157,7 @@ int git_commit__parse_buffer(git_commit *commit, void *data, size_t len) if ((parent = git_commit_lookup(commit->pool, &oid)) == NULL) return -1; - // TODO: push the new commit into the revpool + git_commit_list_insert(&commit->parents, parent); } if (git_commit__parse_time(&commit->commit_time, buffer, buffer_end) < 0) @@ -152,3 +168,30 @@ int git_commit__parse_buffer(git_commit *commit, void *data, size_t len) return 0; } +void git_commit_list_insert(git_commit_list **list, git_commit *commit) +{ + if (*list == NULL) + { + *list = git__malloc(sizeof(git_commit_list)); + + if (*list == NULL) + return; + + (*list)->commit = commit; + (*list)->next = NULL; + } + else + { + git_commit_list *new_list = NULL; + + new_list = git__malloc(sizeof(git_commit_list)); + + if (new_list == NULL) + return; + + new_list->commit = commit; + new_list->next = *list; + + *list = new_list; + } +} |