diff options
Diffstat (limited to 'git_refs.py')
| -rw-r--r-- | git_refs.py | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/git_refs.py b/git_refs.py index debd4cbf..2d4a8090 100644 --- a/git_refs.py +++ b/git_refs.py | |||
| @@ -1,5 +1,3 @@ | |||
| 1 | # -*- coding:utf-8 -*- | ||
| 2 | # | ||
| 3 | # Copyright (C) 2009 The Android Open Source Project | 1 | # Copyright (C) 2009 The Android Open Source Project |
| 4 | # | 2 | # |
| 5 | # Licensed under the Apache License, Version 2.0 (the "License"); | 3 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| @@ -18,12 +16,14 @@ import os | |||
| 18 | from repo_trace import Trace | 16 | from repo_trace import Trace |
| 19 | import platform_utils | 17 | import platform_utils |
| 20 | 18 | ||
| 21 | HEAD = 'HEAD' | 19 | HEAD = 'HEAD' |
| 22 | R_CHANGES = 'refs/changes/' | 20 | R_CHANGES = 'refs/changes/' |
| 23 | R_HEADS = 'refs/heads/' | 21 | R_HEADS = 'refs/heads/' |
| 24 | R_TAGS = 'refs/tags/' | 22 | R_TAGS = 'refs/tags/' |
| 25 | R_PUB = 'refs/published/' | 23 | R_PUB = 'refs/published/' |
| 26 | R_M = 'refs/remotes/m/' | 24 | R_WORKTREE = 'refs/worktree/' |
| 25 | R_WORKTREE_M = R_WORKTREE + 'm/' | ||
| 26 | R_M = 'refs/remotes/m/' | ||
| 27 | 27 | ||
| 28 | 28 | ||
| 29 | class GitRefs(object): | 29 | class GitRefs(object): |
| @@ -131,11 +131,14 @@ class GitRefs(object): | |||
| 131 | base = os.path.join(self._gitdir, prefix) | 131 | base = os.path.join(self._gitdir, prefix) |
| 132 | for name in platform_utils.listdir(base): | 132 | for name in platform_utils.listdir(base): |
| 133 | p = os.path.join(base, name) | 133 | p = os.path.join(base, name) |
| 134 | if platform_utils.isdir(p): | 134 | # We don't implement the full ref validation algorithm, just the simple |
| 135 | # rules that would show up in local filesystems. | ||
| 136 | # https://git-scm.com/docs/git-check-ref-format | ||
| 137 | if name.startswith('.') or name.endswith('.lock'): | ||
| 138 | pass | ||
| 139 | elif platform_utils.isdir(p): | ||
| 135 | self._mtime[prefix] = os.path.getmtime(base) | 140 | self._mtime[prefix] = os.path.getmtime(base) |
| 136 | self._ReadLoose(prefix + name + '/') | 141 | self._ReadLoose(prefix + name + '/') |
| 137 | elif name.endswith('.lock'): | ||
| 138 | pass | ||
| 139 | else: | 142 | else: |
| 140 | self._ReadLoose1(p, prefix + name) | 143 | self._ReadLoose1(p, prefix + name) |
| 141 | 144 | ||
| @@ -144,7 +147,7 @@ class GitRefs(object): | |||
| 144 | with open(path) as fd: | 147 | with open(path) as fd: |
| 145 | mtime = os.path.getmtime(path) | 148 | mtime = os.path.getmtime(path) |
| 146 | ref_id = fd.readline() | 149 | ref_id = fd.readline() |
| 147 | except (IOError, OSError): | 150 | except (OSError, UnicodeError): |
| 148 | return | 151 | return |
| 149 | 152 | ||
| 150 | try: | 153 | try: |
