From be99073e411b835942a4035b4a24a0a3beb87fcd Mon Sep 17 00:00:00 2001 From: Sverre Rabbelier Date: Tue, 24 Jun 2008 22:08:37 +0200 Subject: [PATCH] gitstats: Added with_exceptions=False to 'git rev-parse --verify' We don't want GitPython to throw an exception when the command exits with non-zero status. This happens whenever a invalid ref was passed, instead we just want it to not return a hash, which we then handle ourselves. --- src/git_stats/commit.py | 4 ++-- src/git_stats/parse.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/git_stats/commit.py b/src/git_stats/commit.py index e40627b..480442a 100644 --- a/src/git_stats/commit.py +++ b/src/git_stats/commit.py @@ -165,14 +165,14 @@ def hasParent(commit): git = Git(".") - hash = git.rev_parse("--verify", commit) + hash = git.rev_parse("--verify", commit, with_exceptions=False) if not hash: return False hash = hash + "^" - parent = git.rev_parse("--verify", hash) + parent = git.rev_parse("--verify", hash, with_exceptions=False) if not parent: return False diff --git a/src/git_stats/parse.py b/src/git_stats/parse.py index 3b266a4..baa802b 100644 --- a/src/git_stats/parse.py +++ b/src/git_stats/parse.py @@ -35,7 +35,7 @@ def _check_commit(option, opt, value): """ git = Git(".") - rev = git.rev_parse("--verify", value) + rev = git.rev_parse("--verify", value, with_exceptions=False) if not rev: raise OptionValueError("Unknown commit '" + value + "'") -- 2.11.4.GIT