summaryrefslogtreecommitdiff
path: root/git/test/test_refs.py
diff options
context:
space:
mode:
Diffstat (limited to 'git/test/test_refs.py')
-rw-r--r--git/test/test_refs.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/git/test/test_refs.py b/git/test/test_refs.py
index f0473871..092861da 100644
--- a/git/test/test_refs.py
+++ b/git/test/test_refs.py
@@ -290,6 +290,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: