diff options
author | Vicent Marti <tanoku@gmail.com> | 2010-12-02 04:42:33 +0200 |
---|---|---|
committer | Vicent Marti <tanoku@gmail.com> | 2010-12-02 04:42:33 +0200 |
commit | 41109a7e7eb4544dc64c563d947f6655d45c1a28 (patch) | |
tree | d1f577bb368c0d3d61846eda4f5ccdb0aeba8874 /src/commit.c | |
parent | c4034e63f358cfed6bd851a831c50dbcd5006ffe (diff) | |
parent | eb095435f338b97f305148e122d6e12fd81621ca (diff) | |
download | libgit2-41109a7e7eb4544dc64c563d947f6655d45c1a28.tar.gz |
Merge branch 'commitparents' of https://github.com/JustinLove/libgit2 into JustinLove-commitparents
Diffstat (limited to 'src/commit.c')
-rw-r--r-- | src/commit.c | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/src/commit.c b/src/commit.c index 6fcbfd734..8af92bff2 100644 --- a/src/commit.c +++ b/src/commit.c @@ -257,6 +257,35 @@ time_t git_commit_time(git_commit *commit) return commit->commit_time; } +unsigned int git_commit_parentcount(git_commit *commit) +{ + git_commit_parents *parent; + unsigned int count = 0; + + assert(commit); + CHECK_FULL_PARSE(); + + for (parent = commit->parents; parent != NULL; parent = parent->next) { + count++; + } + + return count; +} + +git_commit * git_commit_parent(git_commit *commit, unsigned int n) +{ + git_commit_parents *parent; + + assert(commit); + CHECK_FULL_PARSE(); + + for (parent = commit->parents; parent != NULL && n > 0; parent = parent->next) { + n--; + } + + return parent ? parent->commit : NULL; +} + void git_commit_set_tree(git_commit *commit, git_tree *tree) { assert(commit && tree); |