summaryrefslogtreecommitdiff
path: root/lib/git/objects/base.py
diff options
context:
space:
mode:
authorSebastian Thiel <byronimo@gmail.com>2009-10-12 17:40:13 +0200
committerSebastian Thiel <byronimo@gmail.com>2009-10-12 17:40:13 +0200
commitaf9e37c5c8714136974124621d20c0436bb0735f (patch)
tree08edae86f04c89db712e70984fd569c5a6a6a6c0 /lib/git/objects/base.py
parent4c73e9cd66c77934f8a262b0c1bab9c2f15449ba (diff)
downloadgitpython-af9e37c5c8714136974124621d20c0436bb0735f.tar.gz
IndexObjects are now checking their slots to raise a proper error message in case someone tries to access an unset path or mode - this information cannot be retrieved afterwards as IndexObject information is kept in the object that pointed at them. To find this information, one would have to search all objects which is not feasible
Diffstat (limited to 'lib/git/objects/base.py')
-rw-r--r--lib/git/objects/base.py9
1 files changed, 8 insertions, 1 deletions
diff --git a/lib/git/objects/base.py b/lib/git/objects/base.py
index 5007f3a1..d3e0d943 100644
--- a/lib/git/objects/base.py
+++ b/lib/git/objects/base.py
@@ -120,8 +120,15 @@ class IndexObject(Object):
if isinstance(mode, basestring):
self.mode = self._mode_str_to_int(mode)
+ def _set_cache_(self, attr):
+ if attr in self.__slots__:
+ # they cannot be retrieved lateron ( not without searching for them )
+ raise AttributeError( "path and mode attributes must have been set during %s object creation" % type(self).__name__ )
+ else:
+ super(IndexObject, self)._set_cache_(attr)
+
@classmethod
- def _mode_str_to_int( cls, modestr ):
+ def _mode_str_to_int(cls, modestr):
"""
``modestr``
string like 755 or 644 or 100644 - only the last 3 chars will be used