summaryrefslogtreecommitdiff
path: root/src/graph.c
diff options
context:
space:
mode:
authorArthur Schreiber <schreiber.arthur@googlemail.com>2014-01-28 19:39:14 +0100
committerArthur Schreiber <schreiber.arthur@googlemail.com>2014-01-28 19:39:14 +0100
commite7c16943f4551830a148995640f87bec2fe08e8f (patch)
treee309913211b29ac99fd0c8a129bdc8f8bcc6dd6b /src/graph.c
parenta1a9d0bd484edb26c579820190d8f5fda24276ef (diff)
downloadlibgit2-e7c16943f4551830a148995640f87bec2fe08e8f.tar.gz
Add `git_graph_descendant_of`.
Diffstat (limited to 'src/graph.c')
-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);
+}