Skip to content

Commit af9e37c

Browse files
committed
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
1 parent 4c73e9c commit af9e37c

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

lib/git/objects/base.py

+8-1
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,15 @@ def __init__(self, repo, id, mode=None, path=None):
120120
if isinstance(mode, basestring):
121121
self.mode = self._mode_str_to_int(mode)
122122

123+
def _set_cache_(self, attr):
124+
if attr in self.__slots__:
125+
# they cannot be retrieved lateron ( not without searching for them )
126+
raise AttributeError( "path and mode attributes must have been set during %s object creation" % type(self).__name__ )
127+
else:
128+
super(IndexObject, self)._set_cache_(attr)
129+
123130
@classmethod
124-
def _mode_str_to_int( cls, modestr ):
131+
def _mode_str_to_int(cls, modestr):
125132
"""
126133
``modestr``
127134
string like 755 or 644 or 100644 - only the last 3 chars will be used

0 commit comments

Comments
 (0)