From f6102b349cbef03667d5715fcfae3161701a472d Mon Sep 17 00:00:00 2001 From: Sebastian Thiel Date: Fri, 4 Dec 2009 14:20:41 +0100 Subject: Reference: reading of commit data is now safer and handles non-existing paths - previously it would run into a code-branch I forgot --- lib/git/refs.py | 6 ++++-- lib/git/utils.py | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) (limited to 'lib') 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())) -- cgit v1.2.3