bisect-kit: revise git_util.is_ancestor_commit
Handle if commits don't exist.
BUG=None
TEST=unit test
Change-Id: I7d9bbbad1fa5a5661e736584c905a61850f1ba57
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/bisect-kit/+/2622687
Tested-by: Kuang-che Wu <kcwu@chromium.org>
Auto-Submit: Kuang-che Wu <kcwu@chromium.org>
Commit-Queue: Zheng-Jie Chang <zjchang@chromium.org>
Reviewed-by: Zheng-Jie Chang <zjchang@chromium.org>
diff --git a/bisect_kit/git_util.py b/bisect_kit/git_util.py
index 3f8f4f5..588cd5a 100644
--- a/bisect_kit/git_util.py
+++ b/bisect_kit/git_util.py
@@ -346,13 +346,16 @@
True only if `old` is the ancestor of `new`. One commit is not considered
as ancestor of itself.
"""
- return util.check_output(
- 'git',
- 'rev-list',
- '--ancestry-path',
- '-1',
- '%s..%s' % (old, new),
- cwd=git_repo) != ''
+ try:
+ return util.check_output(
+ 'git',
+ 'rev-list',
+ '--ancestry-path',
+ '-1',
+ '%s..%s' % (old, new),
+ cwd=git_repo) != ''
+ except subprocess.CalledProcessError:
+ return False
def _parse_commit_object(s):