summaryrefslogtreecommitdiffstats
path: root/project.py
diff options
context:
space:
mode:
authorRemy Bohmer <github@bohmer.net>2020-11-20 21:19:10 +0100
committerMike Frysinger <vapier@google.com>2020-11-20 20:53:43 +0000
commit44bc9643ed1b53ef72a0f4089c80ca8ef7310c7a (patch)
tree87d9dc77c608ca45a98cbb4deb17911730535dd6 /project.py
parentd7f8683daf1d47bb060a1f054453be6779accede (diff)
downloadgit-repo-44bc9643ed1b53ef72a0f4089c80ca8ef7310c7a.tar.gz
Always use Unix EOL for worktree .git and gitdir files
Worktree .git and gitdir reference files are written by Git with Unix line ending, even on Windows & macOS. The conversion to relative paths makes these files end with DOS line endings in Windows. The Git integration in Visual Studio 2019 cannot deal with these DOS line endings and considers these worktrees invalid. Signed-off-by: Remy Bohmer <github@bohmer.net> Change-Id: I088cfd994f3cc31db4e0ca7791fa0a4ee3ac222f Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/289310 Reviewed-by: Mike Frysinger <vapier@google.com> Tested-by: Remy Bohmer <linux@bohmer.net>
Diffstat (limited to 'project.py')
-rw-r--r--project.py10
1 files changed, 6 insertions, 4 deletions
diff --git a/project.py b/project.py
index f838c6f4..ad7d59ae 100644
--- a/project.py
+++ b/project.py
@@ -2702,12 +2702,14 @@ class Project(object):
2702 # Some platforms (e.g. Windows) won't let us update dotgit in situ because 2702 # Some platforms (e.g. Windows) won't let us update dotgit in situ because
2703 # of file permissions. Delete it and recreate it from scratch to avoid. 2703 # of file permissions. Delete it and recreate it from scratch to avoid.
2704 platform_utils.remove(dotgit) 2704 platform_utils.remove(dotgit)
2705 # Use relative path from checkout->worktree. 2705 # Use relative path from checkout->worktree & maintain Unix line endings
2706 with open(dotgit, 'w') as fp: 2706 # on all OS's to match git behavior.
2707 with open(dotgit, 'w', newline='\n') as fp:
2707 print('gitdir:', os.path.relpath(git_worktree_path, self.worktree), 2708 print('gitdir:', os.path.relpath(git_worktree_path, self.worktree),
2708 file=fp) 2709 file=fp)
2709 # Use relative path from worktree->checkout. 2710 # Use relative path from worktree->checkout & maintain Unix line endings
2710 with open(os.path.join(git_worktree_path, 'gitdir'), 'w') as fp: 2711 # on all OS's to match git behavior.
2712 with open(os.path.join(git_worktree_path, 'gitdir'), 'w', newline='\n') as fp:
2711 print(os.path.relpath(dotgit, git_worktree_path), file=fp) 2713 print(os.path.relpath(dotgit, git_worktree_path), file=fp)
2712 2714
2713 self._InitMRef() 2715 self._InitMRef()