summaryrefslogtreecommitdiff
path: root/lib/git/refs.py
diff options
context:
space:
mode:
Diffstat (limited to 'lib/git/refs.py')
-rw-r--r--lib/git/refs.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/lib/git/refs.py b/lib/git/refs.py
index bedca7b2..4941e0a6 100644
--- a/lib/git/refs.py
+++ b/lib/git/refs.py
@@ -214,6 +214,19 @@ class SymbolicReference(object):
# alias
ref = reference
+ def is_valid(self):
+ """
+ Returns
+ True if the reference is valid, hence it can be read and points to
+ a valid object or reference.
+ """
+ try:
+ self.commit
+ except (OSError, ValueError):
+ return False
+ else:
+ return True
+
@property
def is_detached(self):
"""