summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/commit.c15
-rw-r--r--src/git/commit.h8
2 files changed, 23 insertions, 0 deletions
diff --git a/src/commit.c b/src/commit.c
index 6fcbfd734..b8d9f8784 100644
--- a/src/commit.c
+++ b/src/commit.c
@@ -257,6 +257,21 @@ 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;
+}
+
void git_commit_set_tree(git_commit *commit, git_tree *tree)
{
assert(commit && tree);
diff --git a/src/git/commit.h b/src/git/commit.h
index 8cb3401b6..cc4e7a073 100644
--- a/src/git/commit.h
+++ b/src/git/commit.h
@@ -94,6 +94,14 @@ GIT_EXTERN(const git_person *) git_commit_author(git_commit *commit);
GIT_EXTERN(const git_tree *) git_commit_tree(git_commit *commit);
/**
+ * Get the number of parents of this commit
+ *
+ * @param commit a previously loaded commit.
+ * @return integer of count of parents
+ */
+GIT_EXTERN(unsigned int) git_commit_parentcount(git_commit *commit);
+
+/**
* Add a new parent commit to an existing commit
* @param commit the commit object
* @param new_parent the new commit which will be a parent