From 169b0218b384f04426d7509757a8684f957967bf Mon Sep 17 00:00:00 2001 From: Remy Bohmer Date: Sat, 21 Nov 2020 10:57:52 +0100 Subject: [PATCH] Fix --reference option under Windows When intializing a new repo with the --reference option on Windows 10 the objects/info/alternates in each git repository is created with Windows line endings (\r\n), leading to the following error: error: object directory C://.git/objects? does not exist; check .git/objects/info/alternates This can be fixed by simply using unix line endings on both Windows and unix platforms. Reported-by: Francisco Javier Alvarez Garcia Follow-up-from: I268fe029ede68802c21037b0f2ae8a95afb85e48 Bug: https://crbug.com/gerrit/13208 Change-Id: I6da60c4ca957778b3c42ab6b9ad85c40483f0042 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/289431 Reviewed-by: Mike Frysinger Tested-by: Remy Bohmer --- project.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/project.py b/project.py index ad7d59ae..cb78ff72 100644 --- a/project.py +++ b/project.py @@ -62,7 +62,8 @@ RETRY_JITTER_PERCENT = 0.1 def _lwrite(path, content): lock = '%s.lock' % path - with open(lock, 'w') as fd: + # Maintain Unix line endings on all OS's to match git behavior. + with open(lock, 'w', newline='\n') as fd: fd.write(content) try: