diff options
author | Mike Frysinger <vapier@google.com> | 2020-02-21 18:55:07 -0500 |
---|---|---|
committer | David Pursehouse <dpursehouse@collab.net> | 2020-02-22 04:39:55 +0000 |
commit | 75264789c04bbdaffd479ab7725c85b1b8876d8e (patch) | |
tree | 81950ac125fc73fd4d26d86804342709944b36eb /project.py | |
parent | a269b1cb9dc21dfd598bfea3766206b606ad4589 (diff) | |
download | git-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>
Diffstat (limited to 'project.py')
-rw-r--r-- | project.py | 3 |
1 files changed, 3 insertions, 0 deletions
@@ -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), |