mirror of
https://gerrit.googlesource.com/git-repo
synced 2024-12-21 07:16:21 +00:00
Fix drive mounted directory on Windows
On my Windows machine, I mount drive D: to the directory C:\src. The old implementation returns the incorrect 'C:\\??\\Volume{ad2eb15e-f293-4d48-a448-54757d95a97c}' result, which breaks the repo init command. With the use of os.path.realpath, it can return 'D:\\' correctly. Change-Id: Ia5f53989055125cb282d4123cf55d060718aa1ff Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/416580 Reviewed-by: Greg Edelston <gredelston@google.com> Tested-by: Kaiyi Li <kaiyili@google.com> Commit-Queue: Kaiyi Li <kaiyili@google.com>
This commit is contained in:
parent
4406642e20
commit
159389f0da
@ -259,24 +259,4 @@ def realpath(path):
|
|||||||
|
|
||||||
Availability: Windows, Unix.
|
Availability: Windows, Unix.
|
||||||
"""
|
"""
|
||||||
if isWindows():
|
|
||||||
current_path = os.path.abspath(path)
|
|
||||||
path_tail = []
|
|
||||||
for c in range(0, 100): # Avoid cycles
|
|
||||||
if islink(current_path):
|
|
||||||
target = readlink(current_path)
|
|
||||||
current_path = os.path.join(
|
|
||||||
os.path.dirname(current_path), target
|
|
||||||
)
|
|
||||||
else:
|
|
||||||
basename = os.path.basename(current_path)
|
|
||||||
if basename == "":
|
|
||||||
path_tail.append(current_path)
|
|
||||||
break
|
|
||||||
path_tail.append(basename)
|
|
||||||
current_path = os.path.dirname(current_path)
|
|
||||||
path_tail.reverse()
|
|
||||||
result = os.path.normpath(os.path.join(*path_tail))
|
|
||||||
return result
|
|
||||||
else:
|
|
||||||
return os.path.realpath(path)
|
return os.path.realpath(path)
|
||||||
|
Loading…
Reference in New Issue
Block a user