summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/git/refs.py6
-rw-r--r--lib/git/utils.py2
-rw-r--r--test/git/test_refs.py4
3 files changed, 9 insertions, 3 deletions
diff --git a/lib/git/refs.py b/lib/git/refs.py
index cd903174..bedca7b2 100644
--- a/lib/git/refs.py
+++ b/lib/git/refs.py
@@ -112,6 +112,9 @@ class SymbolicReference(object):
# END for each packed ref
# END handle packed refs
+ if tokens is None:
+ raise ValueError("Reference at %r does not exist" % self.path)
+
# is it a reference ?
if tokens[0] == 'ref:':
return (None, tokens[1])
@@ -417,7 +420,6 @@ class SymbolicReference(object):
def _iter_items(cls, repo, common_path = None):
if common_path is None:
common_path = cls._common_path_default
-
rela_paths = set()
# walk loose refs
@@ -516,7 +518,7 @@ class Reference(SymbolicReference, LazyMixin, Iterable):
"""
if not path.startswith(self._common_path_default+'/'):
- raise ValueError("Cannot instantiate %s from path %s" % ( self.__class__.__name__, path ))
+ raise ValueError("Cannot instantiate %r from path %s" % ( self.__class__.__name__, path ))
super(Reference, self).__init__(repo, path)
diff --git a/lib/git/utils.py b/lib/git/utils.py
index 477f734e..1a624ca2 100644
--- a/lib/git/utils.py
+++ b/lib/git/utils.py
@@ -135,7 +135,7 @@ class LockFile(object):
pid = int(fp.read())
fp.close()
except IOError:
- raise AssertionError("GitConfigParser has a lock but the lock file at %s could not be read" % lock_file)
+ raise AssertionError("The lock file at %s could not be read" % lock_file)
if pid != os.getpid():
raise AssertionError("We claim to own the lock at %s, but it was not owned by our process: %i" % (lock_file, os.getpid()))
diff --git a/test/git/test_refs.py b/test/git/test_refs.py
index 584f6e89..2cddf862 100644
--- a/test/git/test_refs.py
+++ b/test/git/test_refs.py
@@ -274,6 +274,10 @@ class TestRefs(TestBase):
assert ref_new_name.object == orig_obj
assert ref_new_name == ref
# END for each name type
+
+ # References that don't exist trigger an error if we want to access them
+ self.failUnlessRaises(ValueError, getattr, Reference(rw_repo, "refs/doesntexist"), 'commit')
+
# exists, fail unless we force
ex_ref_path = far_away_head.path
self.failUnlessRaises(OSError, ref.rename, ex_ref_path)