summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMike Frysinger <vapier@google.com>2020-02-21 18:55:07 -0500
committerDavid Pursehouse <dpursehouse@collab.net>2020-02-22 04:39:55 +0000
commit75264789c04bbdaffd479ab7725c85b1b8876d8e (patch)
tree81950ac125fc73fd4d26d86804342709944b36eb
parenta269b1cb9dc21dfd598bfea3766206b606ad4589 (diff)
downloadgit-repo-75264789c04bbdaffd479ab7725c85b1b8876d8e.tar.gz
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>
-rw-r--r--project.py3
1 files changed, 3 insertions, 0 deletions
diff --git a/project.py b/project.py
index d83dd2d7..b3b5d5cb 100644
--- a/project.py
+++ b/project.py
@@ -3034,6 +3034,9 @@ class Project(object):
3034 setting = fp.read() 3034 setting = fp.read()
3035 assert setting.startswith('gitdir:') 3035 assert setting.startswith('gitdir:')
3036 git_worktree_path = setting.split(':', 1)[1].strip() 3036 git_worktree_path = setting.split(':', 1)[1].strip()
3037 # Some platforms (e.g. Windows) won't let us update dotgit in situ because
3038 # of file permissions. Delete it and recreate it from scratch to avoid.
3039 platform_utils.remove(dotgit)
3037 # Use relative path from checkout->worktree. 3040 # Use relative path from checkout->worktree.
3038 with open(dotgit, 'w') as fp: 3041 with open(dotgit, 'w') as fp:
3039 print('gitdir:', os.path.relpath(git_worktree_path, self.worktree), 3042 print('gitdir:', os.path.relpath(git_worktree_path, self.worktree),