Treat invalid head ref as absent ref
@@ -59,7 +59,7 @@ class GitRepo(object):
def last_commit(self):
if not self.repo:
return None
- if not self.repo.head:
+ if not self.repo.head or not self.repo.head.is_valid():
return None
if len(self.repo.refs) > 0:
return self.repo.head.commit.hexsha
