Skip to content

Commit 035983d

Browse files
committed
fix: normalize Cygwin paths for separate worktrees
1 parent 84c1bd7 commit 035983d

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

PyGitUp/gitup.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,12 @@
4242

4343
ON_WINDOWS = sys.platform == 'win32'
4444

45+
def normalize_path(path):
46+
if ON_WINDOWS and path and path[0] == '/':
47+
return execute(['cygpath', '-m', path])
48+
49+
return path
50+
4551
###############################################################################
4652
# Setup of 3rd party libs
4753
###############################################################################
@@ -61,8 +67,7 @@
6167

6268
def get_git_dir():
6369
toplevel_dir = execute(['git', 'rev-parse', '--show-toplevel'])
64-
if ON_WINDOWS and toplevel_dir and toplevel_dir[0] == '/':
65-
toplevel_dir = execute(['cygpath', '-m', toplevel_dir])
70+
toplevel_dir = normalize_path(toplevel_dir)
6671

6772
if toplevel_dir is not None \
6873
and os.path.isfile(os.path.join(toplevel_dir, '.git')):
@@ -77,7 +82,8 @@ def get_git_dir():
7782
if inside_worktree == 'true' or Git().version_info[:3] < (2, 5, 0):
7883
return toplevel_dir
7984
else:
80-
return execute(['git', 'rev-parse', '--git-common-dir'])
85+
common_dir = execute(['git', 'rev-parse', '--git-common-dir'])
86+
return normalize_path(common_dir)
8187

8288
return toplevel_dir
8389

0 commit comments

Comments
 (0)