Skip to content

Commit a5a75ab

Browse files
committed
relaxed implementation when comparing symbolic references against other items which don't have a path. Fixed test_refs to work in all cases - it was previously dependent on the order of items returned by the file system
1 parent b7071ce commit a5a75ab

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

git/refs/symbolic.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,9 @@ def __repr__(self):
4646
return '<git.%s "%s">' % (self.__class__.__name__, self.path)
4747

4848
def __eq__(self, other):
49-
return self.path == other.path
49+
if hasattr(other, 'path'):
50+
return self.path == other.path
51+
return False
5052

5153
def __ne__(self, other):
5254
return not ( self == other )

git/test/test_refs.py

+9
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,15 @@ def test_head_reset(self, rw_repo):
290290
assert remotes
291291
for remote in remotes:
292292
refs = remote.refs
293+
294+
# If a HEAD exists, it must be deleted first. Otherwise it might
295+
# end up pointing to an invalid ref it the ref was deleted before.
296+
remote_head_name = "HEAD"
297+
if remote_head_name in refs:
298+
RemoteReference.delete(rw_repo, refs[remote_head_name])
299+
del(refs[remote_head_name])
300+
#END handle HEAD deletion
301+
293302
RemoteReference.delete(rw_repo, *refs)
294303
remote_refs_so_far += len(refs)
295304
for ref in refs:

0 commit comments

Comments
 (0)