diff options
author | Mike Frysinger <vapier@google.com> | 2021-02-27 13:06:27 -0500 |
---|---|---|
committer | Mike Frysinger <vapier@google.com> | 2021-02-28 16:07:20 +0000 |
commit | 4510be51c1e4852258dd97fb043a250a6e3abfc7 (patch) | |
tree | 2b079d582c4024782417eb16de77efc276553ac7 /git_command.py | |
parent | a29424ea6d6f5a38ef9c25141c9f095161dbd3ff (diff) | |
download | git-repo-4510be51c1e4852258dd97fb043a250a6e3abfc7.tar.gz |
git_command: pass GIT_DIR on Windows with /
When using Git under Windows, it seems that Git doesn't always parse
GIT_DIR correctly when it uses the Windows \ form, but does when it
uses / only.
For example, when using worktrees:
$ GIT_DIR='C:\Users\vapier\Desktop\repo\breakpad\tools\test\.git' git worktree list
fatal: not a git repository: ..\..\.repo\worktrees\linux-syscall-support.git\worktrees\test
$ GIT_DIR='C:/Users/vapier/Desktop/repo/breakpad/tools/test/.git' git worktree list
C:/Users/vapier/Desktop/repo/breakpad/.repo/worktrees/linux-syscall-support.git fd00dbbd0c06 (detached HEAD)
..\..\..\..\..\src\src\third_party\lss\.git fd00dbbd0c06 (detached HEAD)
..\..\..\..\..\tools\test\.git fd00dbbd0c06 (detached HEAD)
Change-Id: I666c03ae845ecb55d7f9800731ea6987d3e7f401
Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/298622
Reviewed-by: Michael Mortensen <mmortensen@google.com>
Tested-by: Mike Frysinger <vapier@google.com>
Diffstat (limited to 'git_command.py')
-rw-r--r-- | git_command.py | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/git_command.py b/git_command.py index 8bd4e67e..d06fc77c 100644 --- a/git_command.py +++ b/git_command.py | |||
@@ -285,6 +285,9 @@ class GitCommand(object): | |||
285 | command = [GIT] | 285 | command = [GIT] |
286 | if bare: | 286 | if bare: |
287 | if gitdir: | 287 | if gitdir: |
288 | # Git on Windows wants its paths only using / for reliability. | ||
289 | if platform_utils.isWindows(): | ||
290 | gitdir = gitdir.replace('\\', '/') | ||
288 | env[GIT_DIR] = gitdir | 291 | env[GIT_DIR] = gitdir |
289 | cwd = None | 292 | cwd = None |
290 | command.append(cmdv[0]) | 293 | command.append(cmdv[0]) |