diff --git a/bin/metric_bench/main.py b/bin/metric_bench/main.py index b5fef7c2..631ca7b6 100644 --- a/bin/metric_bench/main.py +++ b/bin/metric_bench/main.py @@ -111,7 +111,7 @@ def noted(notes: list[str]) -> str: def run_scores(run: Entry, top: str) -> tuple[RunScores | None, list[str]] | Failure: """The run's scores, and why each file left out was: git could not show it as UTF-8, or it does not parse.""" - # A tracked name that is not UTF-8 fails the run rather than reading with its bytes replaced: every tool reads git's output through git_repo.git's one contract. + # A tracked name that is not UTF-8 fails the run rather than reading with its bytes replaced: every tool in bin/ but the status line, item 204's, reads git's output through git_repo.git's one contract. listed = git("ls-tree", "-r", "-z", "--name-only", run.commit, cwd=top) if isinstance(listed, Failure): return listed diff --git a/bin/reading_cost/test_reading_cost.py b/bin/reading_cost/test_reading_cost.py index ad128597..e86154ed 100644 --- a/bin/reading_cost/test_reading_cost.py +++ b/bin/reading_cost/test_reading_cost.py @@ -174,6 +174,15 @@ class Located(unittest.TestCase): found = main.located() self.assertEqual(found, Checkout(str(root), str(root), frozenset({"a.txt", "sub/b.txt"}))) + def test_fails_in_a_checkout_whose_path_holds_a_newline(self): + temp = tempfile.TemporaryDirectory() + self.addCleanup(temp.cleanup) + root = pathlib.Path(temp.name, "a\nb") + root.mkdir() + subprocess.run(["git", "init", "--quiet"], check=True, cwd=root, env=isolated_env()) + with contextlib.chdir(root): + self.assertIsInstance(main.located(), Failure) + if __name__ == "__main__": unittest.main()