summaryrefslogtreecommitdiffstats
path: root/project.py
diff options
context:
space:
mode:
authorRenaud Paquay <rpaquay@google.com>2016-11-01 13:48:15 -0700
committerRenaud Paquay <rpaquay@google.com>2017-08-31 12:13:52 -0700
commit2a4be948788dfe5ae9437b048fba229a96bbff2d (patch)
tree27c700887158c27b819992f507dfb2504dc7d101 /project.py
parent9d743397bfceae24a12a566ac1f4d5f968ba2779 (diff)
downloadgit-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
Diffstat (limited to 'project.py')
-rw-r--r--project.py6
1 files changed, 3 insertions, 3 deletions
diff --git a/project.py b/project.py
index 4eca9b67..d4c5afd5 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: