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 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'lib/git/refs.py') 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) -- cgit v1.2.1