summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorVicent Marti <vicent@github.com>2014-01-28 10:50:04 -0800
committerVicent Marti <vicent@github.com>2014-01-28 10:50:04 -0800
commitcd4aa602c9d104f146cdfcb89399438214dc75d2 (patch)
treee309913211b29ac99fd0c8a129bdc8f8bcc6dd6b /src
parenta1a9d0bd484edb26c579820190d8f5fda24276ef (diff)
parente7c16943f4551830a148995640f87bec2fe08e8f (diff)
downloadlibgit2-cd4aa602c9d104f146cdfcb89399438214dc75d2.tar.gz
Merge pull request #2083 from arthurschreiber/arthur/add-git_commit_descendant_of
Add `git_commit_descendant_of`.
Diffstat (limited to 'src')
-rw-r--r--src/graph.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/graph.c b/src/graph.c
index 277f588ca..f39af5ed5 100644
--- a/src/graph.c
+++ b/src/graph.c
@@ -176,3 +176,17 @@ on_error:
git_revwalk_free(walk);
return -1;
}
+
+int git_graph_descendant_of(git_repository *repo, const git_oid *commit, const git_oid *ancestor)
+{
+ git_oid merge_base;
+ int error;
+
+ if (git_oid_equal(commit, ancestor))
+ return 0;
+
+ if ((error = git_merge_base(&merge_base, repo, commit, ancestor) < 0))
+ return error;
+
+ return git_oid_equal(&merge_base, ancestor);
+}