diff options
| author | Renaud Paquay <rpaquay@google.com> | 2016-11-01 13:48:15 -0700 |
|---|---|---|
| committer | Renaud Paquay <rpaquay@google.com> | 2017-08-31 12:13:52 -0700 |
| commit | 2a4be948788dfe5ae9437b048fba229a96bbff2d (patch) | |
| tree | 27c700887158c27b819992f507dfb2504dc7d101 | |
| parent | 9d743397bfceae24a12a566ac1f4d5f968ba2779 (diff) | |
| download | git-repo-2a4be948788dfe5ae9437b048fba229a96bbff2d.tar.gz | |
Handle Windows line endings when reading binary files
Without this change, '.git\HEAD' files, for examples, are sometime
read incorrectly resulting in the current branch to be reset to
"master" when running a "repo init -b xxx" on an already initialized
repository.
Change-Id: I48c7ef85ff81626edf156914329a560e14252f2a
| -rw-r--r-- | git_refs.py | 2 | ||||
| -rw-r--r-- | project.py | 6 |
2 files changed, 4 insertions, 4 deletions
diff --git a/git_refs.py b/git_refs.py index 58c838a63..7feaffb1e 100644 --- a/git_refs.py +++ b/git_refs.py | |||
| @@ -139,7 +139,7 @@ class GitRefs(object): | |||
| 139 | 139 | ||
| 140 | def _ReadLoose1(self, path, name): | 140 | def _ReadLoose1(self, path, name): |
| 141 | try: | 141 | try: |
| 142 | fd = open(path, 'rb') | 142 | fd = open(path) |
| 143 | except IOError: | 143 | except IOError: |
| 144 | return | 144 | return |
| 145 | 145 | ||
diff --git a/project.py b/project.py index 4eca9b679..d4c5afd57 100644 --- a/project.py +++ b/project.py | |||
| @@ -1258,7 +1258,7 @@ class Project(object): | |||
| 1258 | if is_new: | 1258 | if is_new: |
| 1259 | alt = os.path.join(self.gitdir, 'objects/info/alternates') | 1259 | alt = os.path.join(self.gitdir, 'objects/info/alternates') |
| 1260 | try: | 1260 | try: |
| 1261 | fd = open(alt, 'rb') | 1261 | fd = open(alt) |
| 1262 | try: | 1262 | try: |
| 1263 | alt_dir = fd.readline().rstrip() | 1263 | alt_dir = fd.readline().rstrip() |
| 1264 | finally: | 1264 | finally: |
| @@ -2691,11 +2691,11 @@ class Project(object): | |||
| 2691 | else: | 2691 | else: |
| 2692 | path = os.path.join(self._project.worktree, '.git', HEAD) | 2692 | path = os.path.join(self._project.worktree, '.git', HEAD) |
| 2693 | try: | 2693 | try: |
| 2694 | fd = open(path, 'rb') | 2694 | fd = open(path) |
| 2695 | except IOError as e: | 2695 | except IOError as e: |
| 2696 | raise NoManifestException(path, str(e)) | 2696 | raise NoManifestException(path, str(e)) |
| 2697 | try: | 2697 | try: |
| 2698 | line = fd.read() | 2698 | line = fd.readline() |
| 2699 | finally: | 2699 | finally: |
| 2700 | fd.close() | 2700 | fd.close() |
| 2701 | try: | 2701 | try: |
