Skip to content

Commit c0c9596

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 c0c9596

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
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 & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -190,9 +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()) :]
193+
abs_path, cwd = os.path.abspath(path), os.getcwd()
194+
common = os.path.commonpath([cwd, abs_path])
195+
if len(common) == len(cwd):
196+
return "." + abs_path[len(common) :]
196197
return path
197198

198199

0 commit comments

Comments
 (0)