Answer principles round 1: 0 🔴, 2 🟡; test every guard, name a non-UTF-8 file name as an exit 1, fail on a malformed rev-parse

This commit is contained in:
2026-10-21 20:05:36 +02:00
parent 3fc6790bee
commit 3ae89c3acf
4 changed files with 44 additions and 18 deletions
+3 -1
View File
@@ -115,7 +115,9 @@ def located() -> Checkout | Failure:
found = git("rev-parse", "--path-format=absolute", "--show-toplevel", "--git-common-dir")
if isinstance(found, Failure):
return found
top, common = found.splitlines()
if len(lines := found.splitlines()) != 2:
return Failure(f"git rev-parse printed {found!r}, not a checkout's top folder and git directory on two lines")
top, common = lines
listed = git("ls-files", "-z", cwd=top)
if isinstance(listed, Failure):
return listed