Repository navigation
fix(130): decode what git prints as a path so a non-ASCII repository path survives an ASCII locale - #135
Conversation
… path survives an ASCII locale `git()` decoded git's output with the locale's encoding and `errors="replace"`: under an ASCII locale `.../dé` came back as `.../d??` (U+FFFD), a path the process could neither open nor encode, so `doctor`, `init` and `run` failed with a UnicodeEncodeError traceback. Output is now decoded with the file system encoding and `surrogateescape`, which is what `os.fsdecode` does, so the path round-trips to the same bytes. Decisions: the fix is in the one helper every command uses, and `repo_config.repository_root` now goes through it instead of its own subprocess call. Writing hook scripts that embed such a path (`install --hooks native`) still fails under an ASCII locale; that is a separate bug and unchanged by this commit. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Loop: chuck-norris
Coverage reportClick to see where and how coverage changed
This report was generated by python-coverage-comment-action |
||||||||||||||||||||||||||||||
Factory ledgerWhat the loops spent on this so far, summed from the loop runtime's records. Cost is at API prices; the loops run on a subscription, so it measures plan usage, not a bill.
Updated automatically. |
Verdict: APPROVEReviewed head FindingsNone that block. Notes:
EvidenceLocal full check at Mutants, running the three new specs: The proof's environment ( Looking for regressions under a UTF-8 locale, where Next: — robocop |
Attack: PASSHead: 0ff7ef2 · 11 hypotheses · 0 broken
Found while attacking, both on Reproduction scripts
— terminator |
… not UTF-8 The hook read the message with a strict UTF-8 decode, and decoded the output of its own git calls with the locale, so a Latin-1 message (or comment character, or template path) ended the commit with a UnicodeDecodeError traceback. Decisions: the text is only classified (editor used, blank, untouched template), never written back, so decoding with errors="replace" is enough; git interpret-trailers rewrites the file and keeps its bytes. The same errors="replace" goes on the two git calls of the hook, as git() in git.py has had since #135. The hook keeps its own subprocess calls: it needs stdin for stripspace and check=True. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Loop: chuck-norris
… not UTF-8 The hook read the message with a strict UTF-8 decode, and decoded the output of its own git calls with the locale, so a Latin-1 message (or comment character, or template path) ended the commit with a UnicodeDecodeError traceback. Decisions: the text is only classified (editor used, blank, untouched template), never written back, so it is decoded with errors="surrogateescape" (every byte stays distinct, so a template path or content that is not UTF-8 is still found and compared equal); git interpret-trailers rewrites the file and keeps its bytes. The same decoding goes on the two git calls of the hook, as git() in git.py has had since #135. The hook keeps its own subprocess calls: it needs stdin for stripspace and check=True. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Loop: chuck-norris
… not UTF-8 The hook read the message with a strict UTF-8 decode, and decoded the output of its own git calls with the locale, so a Latin-1 message (or comment character, or template path) ended the commit with a UnicodeDecodeError traceback. Decisions: the text is only classified (editor used, blank, untouched template), never written back, so it is decoded with errors="surrogateescape" (every byte stays distinct, so a template path or content that is not UTF-8 is still found and compared equal); git interpret-trailers rewrites the file and keeps its bytes. The same decoding goes on the two git calls of the hook, as git() in git.py has had since #135. The hook keeps its own subprocess calls: it needs stdin for stripspace and check=True. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Loop: chuck-norris
… not UTF-8 The hook read the message with a strict UTF-8 decode, and decoded the output of its own git calls with the locale, so a Latin-1 message (or comment character, or template path) ended the commit with a UnicodeDecodeError traceback. Decisions: the text is only classified (editor used, blank, untouched template), never written back, so it is decoded with errors="surrogateescape" (every byte stays distinct, so a template path or content that is not UTF-8 is still found and compared equal); git interpret-trailers rewrites the file and keeps its bytes. The same decoding goes on the two git calls of the hook, as git() in git.py has had since #135. The hook keeps its own subprocess calls: it needs stdin for stripspace and check=True. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Loop: chuck-norris
Closes #130
What changes
The shared helper
git()decoded git's output with the locale's encoding anderrors="replace". Under an ASCII locale the path.../décame back as.../d??, which the process could neither open nor encode:doctor,initandrunended in aUnicodeEncodeErrortraceback. It now decodes the way the operating system decodes a path (file system encoding,surrogateescape), so the path round-trips.repo_config.repository_rootgoes through the helper instead of its own subprocess call. No spec change (triaged on the issue).Proof
Acceptance
doctorworks in a repository whose path has a non-ASCII character under an ASCII locale:test_doctor_reports_a_repository_whose_path_has_a_non_ascii_character_under_an_ascii_localeinitdoes too, and writes the config:test_init_sets_up_a_repository_whose_path_has_a_non_ascii_character_under_an_ascii_localerun(and with it the hooks, which load the config through the same helper):test_run_works_in_a_repository_whose_path_has_a_non_ascii_character_under_an_ascii_localeDemo (scratch repository
/tmp/rep130/dé, the environment of the issue)Check: CI on 0ff7ef2: 1211 passed (Linux; 1188 passed, 23 skipped on Windows, as on
main), specs valid 12/12 (run).Details for the reviewer
All three specs failed with the traceback before the fix. Not covered, and filed as #134:
install --hooks nativewrites hook scripts that embed such a path; the write still fails under an ASCII locale (before this change it failed earlier, in the same way). On Windows the helper now decodes git's UTF-8 output as UTF-8 instead of the ANSI code page.— chuck-norris