summaryrefslogtreecommitdiff
path: root/git/repo/base.py
diff options
context:
space:
mode:
authorSebastian Thiel <byronimo@gmail.com>2015-07-21 21:19:42 +0200
committerSebastian Thiel <byronimo@gmail.com>2015-07-21 21:19:42 +0200
commit1883eb9282468b3487d24f143b219b7979d86223 (patch)
treec4ef1f3d52a35a289c6e920dbcf79666cda2952c /git/repo/base.py
parentf360ecd7b2de173106c08238ec60db38ec03ee9b (diff)
parent65c07d64a7b1dc85c41083c60a8082b3705154c3 (diff)
downloadgitpython-1883eb9282468b3487d24f143b219b7979d86223.tar.gz
Merge pull request #322 from bwrsandman/is_ancestor
Implement is_ancestor
Diffstat (limited to 'git/repo/base.py')
-rw-r--r--git/repo/base.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/git/repo/base.py b/git/repo/base.py
index b0411235..16fb58e5 100644
--- a/git/repo/base.py
+++ b/git/repo/base.py
@@ -504,6 +504,21 @@ class Repo(object):
return res
+ def is_ancestor(self, ancestor_rev, rev):
+ """Check if a commit is an ancestor of another
+
+ :param ancestor_rev: Rev which should be an ancestor
+ :param rev: Rev to test against ancestor_rev
+ :return: ``True``, ancestor_rev is an accestor to rev.
+ """
+ try:
+ self.git.merge_base(ancestor_rev, rev, is_ancestor=True)
+ except GitCommandError as err:
+ if err.status == 1:
+ return False
+ raise
+ return True
+
def _get_daemon_export(self):
filename = join(self.git_dir, self.DAEMON_EXPORT_FILE)
return os.path.exists(filename)