Skip to content

Commit d693c12

Browse files
committed
Preserve original letter-casing for displaying
Simplify input path as a relative path to current working directory, while preserving the original letter-casing at best effort.
1 parent 38e9bbe commit d693c12

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

news/6823.bugfix.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Better preserve original casing when a path is displayed.

src/pip/_internal/utils/misc.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -190,10 +190,10 @@ def rmtree_errorhandler(
190190
def display_path(path: str) -> str:
191191
"""Gives the display value for a given path, making it relative to cwd
192192
if possible."""
193-
path = os.path.normcase(os.path.abspath(path))
194-
if path.startswith(os.getcwd() + os.path.sep):
195-
path = "." + path[len(os.getcwd()) :]
196-
return path
193+
rel = os.path.relpath(path)
194+
if rel[:2] == "..":
195+
return path
196+
return os.path.join(".", rel)
197197

198198

199199
def backup_dir(dir: str, ext: str = ".bak") -> str:

0 commit comments

Comments
 (0)