summaryrefslogtreecommitdiffstats
path: root/project.py
diff options
context:
space:
mode:
authorDan Willemsen <dwillemsen@google.com>2015-12-15 13:40:05 -0800
committerDan Willemsen <dwillemsen@google.com>2015-12-15 14:22:40 -0800
commit1a799d14b71c3f694aa62edf99310bc3e1a482d5 (patch)
treede43af900d722c45189dedcd2c30321686af5e77 /project.py
parente9becc079c647f6c9477eed83c0aecb2f591fdf4 (diff)
downloadgit-repo-1a799d14b71c3f694aa62edf99310bc3e1a482d5.tar.gz
Fix prune when bare git has detached head
We don't really use HEAD much in the bare git repositories, but there have been reports of errors in git-symbolic-ref: symbolic-ref: fatal: Refusing to point HEAD outside of refs/ That happen when the bare git repo is in the detached head state. It's possible that previous operations were killed while we were pruning branches. Use DetachHead instead of SetHead if we're restoring the repo into a detached head state. Change-Id: I9062e8957bc70367d3ded399685ac026fbb421fc
Diffstat (limited to 'project.py')
-rw-r--r--project.py7
1 files changed, 4 insertions, 3 deletions
diff --git a/project.py b/project.py
index 50580880..d54e336c 100644
--- a/project.py
+++ b/project.py
@@ -1583,8 +1583,6 @@ class Project(object):
1583 1583
1584 if kill: 1584 if kill:
1585 old = self.bare_git.GetHead() 1585 old = self.bare_git.GetHead()
1586 if old is None:
1587 old = 'refs/heads/please_never_use_this_as_a_branch_name'
1588 1586
1589 try: 1587 try:
1590 self.bare_git.DetachHead(rev) 1588 self.bare_git.DetachHead(rev)
@@ -1596,7 +1594,10 @@ class Project(object):
1596 capture_stderr=True) 1594 capture_stderr=True)
1597 b.Wait() 1595 b.Wait()
1598 finally: 1596 finally:
1599 self.bare_git.SetHead(old) 1597 if ID_RE.match(old):
1598 self.bare_git.DetachHead(old)
1599 else:
1600 self.bare_git.SetHead(old)
1600 left = self._allrefs 1601 left = self._allrefs
1601 1602
1602 for branch in kill: 1603 for branch in kill: