aboutsummaryrefslogtreecommitdiff
path: root/git/test
diff options
context:
space:
mode:
Diffstat (limited to 'git/test')
-rw-r--r--git/test/refs/test_refs.py10
1 files changed, 9 insertions, 1 deletions
diff --git a/git/test/refs/test_refs.py b/git/test/refs/test_refs.py
index e49b23ab..668dd94c 100644
--- a/git/test/refs/test_refs.py
+++ b/git/test/refs/test_refs.py
@@ -140,7 +140,6 @@ class TestRefs(TestBase):
assert len(log) == 1
assert log[0].oldhexsha == pcommit.NULL_HEX_SHA
assert log[0].newhexsha == pcommit.hexsha
-
def test_refs(self):
types_found = set()
@@ -285,6 +284,15 @@ class TestRefs(TestBase):
assert remotes
for remote in remotes:
refs = remote.refs
+
+ # If a HEAD exists, it must be deleted first. Otherwise it might
+ # end up pointing to an invalid ref it the ref was deleted before.
+ remote_head_name = "HEAD"
+ if remote_head_name in refs:
+ RemoteReference.delete(rw_repo, refs[remote_head_name])
+ del(refs[remote_head_name])
+ #END handle HEAD deletion
+
RemoteReference.delete(rw_repo, *refs)
remote_refs_so_far += len(refs)
for ref in refs: