Skip to content

Commit 24bb92d

Browse files
fix #993 and add a test
1 parent 517ed80 commit 24bb92d

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

src/setuptools_scm/_file_finders/git.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ def git_find_files(path: _t.PathT = "") -> list[str]:
9292
toplevel = _git_toplevel(os.fspath(path))
9393
if not is_toplevel_acceptable(toplevel):
9494
return []
95-
fullpath = os.path.normcase(os.path.abspath(os.path.normpath(path)))
95+
fullpath = norm_real(path)
9696
if not fullpath.startswith(toplevel):
9797
log.warning("toplevel mismatch computed %s vs resolved %s ", toplevel, fullpath)
9898
git_files, git_dirs = _git_ls_files_and_dirs(toplevel)

testing/test_file_finder.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,19 @@ def test_case(inwd: WorkDir) -> None:
6969
)
7070

7171

72+
@pytest.mark.skipif(
73+
os.path.normcase("B") != os.path.normcase("b"), reason="case sensitive filesystem"
74+
)
75+
def test_case_cwd_evil(inwd: WorkDir, monkeypatch: pytest.MonkeyPatch) -> None:
76+
(inwd.cwd / "CamelFile").touch()
77+
(inwd.cwd / "file2").touch()
78+
inwd.add_and_commit()
79+
monkeypatch.chdir(inwd.cwd.parent.joinpath(inwd.cwd.name.capitalize()))
80+
assert set(find_files()) == _sep(
81+
{"CamelFile", "file2", "file1", "adir/filea", "bdir/fileb"}
82+
)
83+
84+
7285
@pytest.mark.skipif(sys.platform == "win32", reason="symlinks to dir not supported")
7386
def test_symlink_dir(inwd: WorkDir) -> None:
7487
(inwd.cwd / "adir" / "bdirlink").symlink_to("../bdir")

0 commit comments

Comments
 (0)