diff options
Diffstat (limited to 'project.py')
-rw-r--r-- | project.py | 41 |
1 files changed, 23 insertions, 18 deletions
@@ -3375,24 +3375,29 @@ class Project: | |||
3375 | setting = fp.read() | 3375 | setting = fp.read() |
3376 | assert setting.startswith("gitdir:") | 3376 | assert setting.startswith("gitdir:") |
3377 | git_worktree_path = setting.split(":", 1)[1].strip() | 3377 | git_worktree_path = setting.split(":", 1)[1].strip() |
3378 | # Some platforms (e.g. Windows) won't let us update dotgit in situ | 3378 | |
3379 | # because of file permissions. Delete it and recreate it from scratch | 3379 | # `gitdir` maybe be either relative or absolute depending on the |
3380 | # to avoid. | 3380 | # behavior of the local copy of git, so only convert the path to |
3381 | platform_utils.remove(dotgit) | 3381 | # relative if it needs to be converted. |
3382 | # Use relative path from checkout->worktree & maintain Unix line endings | 3382 | if os.path.isabs(git_worktree_path): |
3383 | # on all OS's to match git behavior. | 3383 | # Some platforms (e.g. Windows) won't let us update dotgit in situ |
3384 | with open(dotgit, "w", newline="\n") as fp: | 3384 | # because of file permissions. Delete it and recreate it from |
3385 | print( | 3385 | # scratch to avoid. |
3386 | "gitdir:", | 3386 | platform_utils.remove(dotgit) |
3387 | os.path.relpath(git_worktree_path, self.worktree), | 3387 | # Use relative path from checkout->worktree & maintain Unix line |
3388 | file=fp, | 3388 | # endings on all OS's to match git behavior. |
3389 | ) | 3389 | with open(dotgit, "w", newline="\n") as fp: |
3390 | # Use relative path from worktree->checkout & maintain Unix line endings | 3390 | print( |
3391 | # on all OS's to match git behavior. | 3391 | "gitdir:", |
3392 | with open( | 3392 | os.path.relpath(git_worktree_path, self.worktree), |
3393 | os.path.join(git_worktree_path, "gitdir"), "w", newline="\n" | 3393 | file=fp, |
3394 | ) as fp: | 3394 | ) |
3395 | print(os.path.relpath(dotgit, git_worktree_path), file=fp) | 3395 | # Use relative path from worktree->checkout & maintain Unix line |
3396 | # endings on all OS's to match git behavior. | ||
3397 | with open( | ||
3398 | os.path.join(git_worktree_path, "gitdir"), "w", newline="\n" | ||
3399 | ) as fp: | ||
3400 | print(os.path.relpath(dotgit, git_worktree_path), file=fp) | ||
3396 | 3401 | ||
3397 | self._InitMRef() | 3402 | self._InitMRef() |
3398 | 3403 | ||