mirror of
https://gerrit.googlesource.com/git-repo
synced 2024-12-21 07:16:21 +00:00
project: fix worktree init under Windows
Git likes to create .git files with read-only permissions which makes it difficult to open+truncate+write in situ under Windows. Delete it before we write the file content to workaround. Change-Id: I3effd96525f0dfe0b90e298b6bf0b856ea26aa03 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/256412 Tested-by: Mike Frysinger <vapier@google.com> Reviewed-by: David Pursehouse <dpursehouse@collab.net>
This commit is contained in:
parent
a269b1cb9d
commit
75264789c0
@ -3034,6 +3034,9 @@ class Project(object):
|
|||||||
setting = fp.read()
|
setting = fp.read()
|
||||||
assert setting.startswith('gitdir:')
|
assert setting.startswith('gitdir:')
|
||||||
git_worktree_path = setting.split(':', 1)[1].strip()
|
git_worktree_path = setting.split(':', 1)[1].strip()
|
||||||
|
# Some platforms (e.g. Windows) won't let us update dotgit in situ because
|
||||||
|
# of file permissions. Delete it and recreate it from scratch to avoid.
|
||||||
|
platform_utils.remove(dotgit)
|
||||||
# Use relative path from checkout->worktree.
|
# Use relative path from checkout->worktree.
|
||||||
with open(dotgit, 'w') as fp:
|
with open(dotgit, 'w') as fp:
|
||||||
print('gitdir:', os.path.relpath(git_worktree_path, self.worktree),
|
print('gitdir:', os.path.relpath(git_worktree_path, self.worktree),
|
||||||
|
Loading…
Reference in New Issue
Block a user