Skip to content

Commit 74b13c5

Browse files
committed
symbolic reference handles different types for comparison more gracefully. Fixed possible issue in test_refs, which occurred in 0.3 previously
1 parent ee9d6b9 commit 74b13c5

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

git/refs/symbolic.py

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

6666
def __eq__(self, other):
67-
return self.path == other.path
67+
if hasattr(other, 'path'):
68+
return self.path == other.path
69+
return False
6870

6971
def __ne__(self, other):
7072
return not ( self == other )

git/test/refs/test_refs.py

+9-1
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,6 @@ def test_heads(self, rw_repo):
140140
assert len(log) == 1
141141
assert log[0].oldhexsha == pcommit.NULL_HEX_SHA
142142
assert log[0].newhexsha == pcommit.hexsha
143-
144143

145144
def test_refs(self):
146145
types_found = set()
@@ -285,6 +284,15 @@ def test_head_reset(self, rw_repo):
285284
assert remotes
286285
for remote in remotes:
287286
refs = remote.refs
287+
288+
# If a HEAD exists, it must be deleted first. Otherwise it might
289+
# end up pointing to an invalid ref it the ref was deleted before.
290+
remote_head_name = "HEAD"
291+
if remote_head_name in refs:
292+
RemoteReference.delete(rw_repo, refs[remote_head_name])
293+
del(refs[remote_head_name])
294+
#END handle HEAD deletion
295+
288296
RemoteReference.delete(rw_repo, *refs)
289297
remote_refs_so_far += len(refs)
290298
for ref in refs:

0 commit comments

Comments
 (0)