summaryrefslogtreecommitdiffstats
path: root/platform_utils.py
diff options
context:
space:
mode:
authorKaiyi Li <kaiyili@google.com>2024-03-27 01:53:22 -0700
committerLUCI <gerrit-scoped@luci-project-accounts.iam.gserviceaccount.com>2024-03-27 14:00:47 +0000
commit159389f0da91e893962923f4aca951f8e6d9a451 (patch)
treeb94008c8d6692ad070f9c7793152cbf0d8c767e4 /platform_utils.py
parent4406642e20d2b984631e6099664058013095ce49 (diff)
downloadgit-repo-159389f0da91e893962923f4aca951f8e6d9a451.tar.gz
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>
Diffstat (limited to 'platform_utils.py')
-rw-r--r--platform_utils.py22
1 files changed, 1 insertions, 21 deletions
diff --git a/platform_utils.py b/platform_utils.py
index 4cf994bc..29060099 100644
--- a/platform_utils.py
+++ b/platform_utils.py
@@ -259,24 +259,4 @@ def realpath(path):
259 259
260 Availability: Windows, Unix. 260 Availability: Windows, Unix.
261 """ 261 """
262 if isWindows(): 262 return os.path.realpath(path)
263 current_path = os.path.abspath(path)
264 path_tail = []
265 for c in range(0, 100): # Avoid cycles
266 if islink(current_path):
267 target = readlink(current_path)
268 current_path = os.path.join(
269 os.path.dirname(current_path), target
270 )
271 else:
272 basename = os.path.basename(current_path)
273 if basename == "":
274 path_tail.append(current_path)
275 break
276 path_tail.append(basename)
277 current_path = os.path.dirname(current_path)
278 path_tail.reverse()
279 result = os.path.normpath(os.path.join(*path_tail))
280 return result
281 else:
282 return os.path.realpath(path)