Merge "Fix prune when bare git has detached head"

This commit is contained in:
Dan Willemsen 2016-02-04 22:44:19 +00:00 committed by Gerrit Code Review
commit 985ac6b946

View File

@ -1583,8 +1583,6 @@ class Project(object):
if kill: if kill:
old = self.bare_git.GetHead() old = self.bare_git.GetHead()
if old is None:
old = 'refs/heads/please_never_use_this_as_a_branch_name'
try: try:
self.bare_git.DetachHead(rev) self.bare_git.DetachHead(rev)
@ -1596,7 +1594,10 @@ class Project(object):
capture_stderr=True) capture_stderr=True)
b.Wait() b.Wait()
finally: finally:
self.bare_git.SetHead(old) if ID_RE.match(old):
self.bare_git.DetachHead(old)
else:
self.bare_git.SetHead(old)
left = self._allrefs left = self._allrefs
for branch in kill: for branch in kill: