@@ -43,7 +43,7 @@ def __repr__(self):
4343 return '<git.%s "%s">' % (self .__class__ .__name__ , self .path )
4444
4545 def __eq__ (self , other ):
46- return self .path == other .path and self . object == other . object
46+ return self .path == other .path
4747
4848 def __ne__ (self , other ):
4949 return not ( self == other )
@@ -203,34 +203,29 @@ class SymbolicReference(object):
203203
204204 A typical example for a symbolic reference is HEAD.
205205 """
206- __slots__ = ("repo" , "name " )
206+ __slots__ = ("repo" , "path " )
207207
208- def __init__ (self , repo , name ):
209- if '/' in name :
210- # NOTE: Actually they can be looking like ordinary refs. Theoretically we handle this
211- # case incorrectly
212- raise ValueError ("SymbolicReferences are not located within a directory, got %s" % name )
213- # END error handling
208+ def __init__ (self , repo , path ):
214209 self .repo = repo
215- self .name = name
210+ self .path = path
216211
217212 def __str__ (self ):
218- return self .name
213+ return self .path
219214
220215 def __repr__ (self ):
221- return '<git.%s "%s">' % (self .__class__ .__name__ , self .name )
216+ return '<git.%s "%s">' % (self .__class__ .__name__ , self .path )
222217
223218 def __eq__ (self , other ):
224- return self .name == other .name
219+ return self .path == other .path
225220
226221 def __ne__ (self , other ):
227222 return not ( self == other )
228223
229224 def __hash__ (self ):
230- return hash (self .name )
225+ return hash (self .path )
231226
232227 def _get_path (self ):
233- return join_path_native (self .repo .path , self .name )
228+ return join_path_native (self .repo .path , self .path )
234229
235230 def _get_commit (self ):
236231 """
@@ -311,7 +306,7 @@ def _set_reference(self, ref):
311306 # checking
312307 # Otherwise we detach it and have to do it manually
313308 if write_value .startswith ('ref:' ):
314- self .repo .git .symbolic_ref (self .name , write_value [5 :])
309+ self .repo .git .symbolic_ref (self .path , write_value [5 :])
315310 return
316311 # END non-detached handling
317312
@@ -346,6 +341,10 @@ def from_path(cls, repo, path):
346341 Return
347342 Instance of SymbolicReference or HEAD
348343 depending on the given path
344+
345+ Note
346+ It enforces that symbolic refs in git are only found in the
347+ root of the .git repository, never within a folder.
349348 """
350349 if not path :
351350 raise ValueError ("Cannot create Symbolic Reference from %r" % path )
@@ -366,10 +365,10 @@ class HEAD(SymbolicReference):
366365 _HEAD_NAME = 'HEAD'
367366 __slots__ = tuple ()
368367
369- def __init__ (self , repo , name = _HEAD_NAME ):
370- if name != self ._HEAD_NAME :
371- raise ValueError ("HEAD instance must point to %r, got %r" % (self ._HEAD_NAME , name ))
372- super (HEAD , self ).__init__ (repo , name )
368+ def __init__ (self , repo , path = _HEAD_NAME ):
369+ if path != self ._HEAD_NAME :
370+ raise ValueError ("HEAD instance must point to %r, got %r" % (self ._HEAD_NAME , path ))
371+ super (HEAD , self ).__init__ (repo , path )
373372
374373
375374 def reset (self , commit = 'HEAD' , index = True , working_tree = False ,
0 commit comments