diff --git a/git_refs.py b/git_refs.py index 3c8a9867..2d4a8090 100644 --- a/git_refs.py +++ b/git_refs.py @@ -131,11 +131,14 @@ class GitRefs(object): base = os.path.join(self._gitdir, prefix) for name in platform_utils.listdir(base): p = os.path.join(base, name) - if platform_utils.isdir(p): + # We don't implement the full ref validation algorithm, just the simple + # rules that would show up in local filesystems. + # https://git-scm.com/docs/git-check-ref-format + if name.startswith('.') or name.endswith('.lock'): + pass + elif platform_utils.isdir(p): self._mtime[prefix] = os.path.getmtime(base) self._ReadLoose(prefix + name + '/') - elif name.endswith('.lock'): - pass else: self._ReadLoose1(p, prefix + name) @@ -144,7 +147,7 @@ class GitRefs(object): with open(path) as fd: mtime = os.path.getmtime(path) ref_id = fd.readline() - except (IOError, OSError): + except (OSError, UnicodeError): return try: