diff options
-rw-r--r-- | project.py | 23 |
1 files changed, 22 insertions, 1 deletions
@@ -3841,8 +3841,29 @@ class Project: | |||
3841 | return self.rev_parse(HEAD) | 3841 | return self.rev_parse(HEAD) |
3842 | return symbolic_head | 3842 | return symbolic_head |
3843 | except GitError as e: | 3843 | except GitError as e: |
3844 | logger.warning( | ||
3845 | "project %s: unparseable HEAD; trying to recover.\n" | ||
3846 | "Check that HEAD ref in .git/HEAD is valid. The error " | ||
3847 | "was: %s", | ||
3848 | self._project.RelPath(local=False), | ||
3849 | e, | ||
3850 | ) | ||
3851 | |||
3852 | # Fallback to direct file reading for compatibility with broken | ||
3853 | # repos, e.g. if HEAD points to an unborn branch. | ||
3844 | path = self.GetDotgitPath(subpath=HEAD) | 3854 | path = self.GetDotgitPath(subpath=HEAD) |
3845 | raise NoManifestException(path, str(e)) | 3855 | try: |
3856 | with open(path) as fd: | ||
3857 | line = fd.readline() | ||
3858 | except OSError: | ||
3859 | raise NoManifestException(path, str(e)) | ||
3860 | try: | ||
3861 | line = line.decode() | ||
3862 | except AttributeError: | ||
3863 | pass | ||
3864 | if line.startswith("ref: "): | ||
3865 | return line[5:-1] | ||
3866 | return line[:-1] | ||
3846 | 3867 | ||
3847 | def SetHead(self, ref, message=None): | 3868 | def SetHead(self, ref, message=None): |
3848 | cmdv = [] | 3869 | cmdv = [] |