Repository navigation
shape-doctor.py: a holder's .gitmodules is split at the first space and at every Unicode line break, and read through a regexp a UTF-8 locale cannot match, so a section name holding a space or a byte that is not UTF-8, or a url holding NEL or U+2028, gives the doctor another mount url than git and make siblings use #668
Description
Goal: the doctor reads a holder's .gitmodules as git and make siblings read it, whatever a section name or a url holds, under any locale.
Filed by lane openRepoShape-3 on Brett Heap's word of 2026-10-16T12:24:41Z ("give #460 to lane 3").
What happens (measured on main d4a7fab9, git 2.43.0):
- A section name holding a space (L22). The section is
[submodule "members/My IRRS"], withpath = members/IRRSand a url.- git lists
submodule.members/My IRRS.path members/IRRS.submodule_configsplits each line at the FIRST space and returns{'': {'members/My': 'IRRS.url <url>'}}. - So
mounted_fromfalls back tohttps://github.com/InkRouter/IRRS.git. - On a holder from the suite's
holderfixture, with a real clone of the member's remote beside it, the doctor givesworking_clone: nulland calls the clone a stranger (other_origin= the remote). siblings.verify_siblingon the same directory givesTrue, andsiblings.submodule_urlsreads the section correctly.- The verdict stays
COMPLIANT, exit 0. But the two tools disagree about one directory, which is what shape-doctor.py: the members row calls a beside-the-holder repository the working clone on its project id alone, where the family's own verifier also requires the origin #146 exists to prevent.
- git lists
- A url holding a Unicode line break (L23).
str.splitlines()splits at\v,\f,\x1c-\x1e,\x85, U+2028 and U+2029, as well as at\nand\r.- A url holding NEL, U+2028, VT or FS (each measured) is read as
<remotes>/caf, andsubmodule_configinvents an entry'': {'': ''}. - git uses the whole url, and
git config -z --listshows it whole. siblings.submodule_urlstruncates it the same way. That half is Tracking: setup, scaffold, family and the shared helpers, creating projects and families #459's, and lane openRepoShape-5's.
- A url holding NEL, U+2028, VT or FS (each measured) is read as
- A section name that is not UTF-8 (L25). The section is
[submodule "members/caf\xe9"].- Under
LC_ALL=C.UTF-8,git config --get-regexp '^submodule\..*\.(path|url)$'exits 1, with or without-z. UnderLC_ALL=Cit exits 0. - Only the
.*that has to match the invalid byte fails.'^submodule\.'and'\.url$'both exit 0, and git's exact-key read (git config --get 'submodule.members/caf\xe9.url', which is howgit submodulereads it) returns the url. - So under a UTF-8 locale,
submodule_configreturns{},mounted_fromfalls back torepository:, andgitmodules_entryreturns(None, None). siblings.submodule_urls(--list, no regexp) reads the url.- Read from the code, not run end to end: given
(None, None),submodule_urlsays git finds no url,url_less_members(:7270-7286) calls that member url-less, andcheckout_reach(:4634-4636) answersno-urlfor a mount that needs a checkout, where git would update it.
- Under
Where it is (main d4a7fab9), in shape-doctor.py:
-
:6987-7036,submodule_config:git config -f .gitmodules --get-regexp '^submodule\..*\.(path|url)$'at:7026-7028;.strip()andsplitlines()at:7031-7032;line.partition(" ")at:7033.
mounted_from(:7039-7076) reads its result. -
:4344-4392,gitmodules_entry. It runsgit config -z <source> --get-regexpwith the same regexp (:4379), so it has L25's exposure. Its-z, together withsection_url'srecord.partition("\n")(:4394-4420, shape-doctor.py'slegsNEXT after #354 does not fit four edge states: a populated mount with no.gitbut its gitdir kept is sent tovalidate-pins.pyunder a sentence saying no update cures it, though the git line does; an unborn HEAD gets the gate, which sayspins okwhile the row stays red; an empty mount with no.gitmodulessection gets a git line that exits 128; and an empty mount whose pin is not 40 hex gets no "run the doctor again" #414), already cures L22 and L23 there. -
The house way to read the whole file is
templates/family-root/scripts/validate-family.py:808-851(_gitmodules_sections) andscripts/family.py:5831. Both rungit config -z --file .gitmodules --list, with no regexp, split the records at NUL, and split each key from its value at the first\n. Measured:-z --listreads the Latin-1 section under both locales. -
A docstring sentence Tracking: the test suite, CI and the docs #461 flags.
submodule_config's docstring (:7021-7022) says "It is also what the row PRINTS, and a lone surrogate is a string no UTF-8 stream can write". Tracking: the test suite, CI and the docs #461 records that reason as not decisive (R432 N1): the table goes throughascii_text, and--jsonthroughjson.dumpswithensure_ascii, so neither would raise.
The change:
- One reading for both
submodule_configandgitmodules_entry. Usegit config -z <source> --list, with no regexp, so the locale cannot matter:- split the records at NUL;
- split each key from its value at the first
\n(a key cannot hold one; a value can); - keep the keys that start with
submodule.. The name is everything betweensubmodule.and the LAST., and the field is what follows. Onlypathandurlcount; - decode with
errors="replace", as now (shape-doctor.pysubmodule_configreads a family holder's.gitmodulesthroughgit_out, which decodes strictly, insideexcept (Refusal, OSError), so a member url that is not UTF-8 raises a UnicodeDecodeError thatrun_checksdoes not catch andshape-doctor.py --rootends in a traceback, exit 1 (also the code of a finding), with no verdict, wherevalidate-family.pyandsiblings.pyread the same file as bytes or witherrors="replace"#432, scripts/shape_advisory.pyrepository_namesand shape-doctor.pyorigin_urlandorigin_namereadgit remote get-url originthroughgit_outand catchRefusalandOSErroronly, so an origin URL that is not UTF-8 makesreadanswernot-answered(a single repository loses the Triad advisory, a leg clone its pointer to the assembly root) and endsshape-doctor.py --rootin a UnicodeDecodeError traceback, exit 1, where an ASCII origin gives NOT A SHAPE ROOT, exit 2 #385); - the later value wins, as git reads it.
- Keep where each one reads.
submodule_configkeeps reading the working tree's.gitmodulesalone, asmake siblingsdoes.gitmodules_entrykeeps git's order: the working tree, else:.gitmodules, elseHEAD:.gitmodules. - No match becomes an empty result. With
--list, a read that succeeds exits 0 even when no section matches, so "read, and no section gives that path" is now an empty result, not exit 1. section_urlstays pure. Since--listreturns every key, it now drops every key that is notsubmodule.<name>.pathor.url.- Fold in Tracking: the test suite, CI and the docs #461's R432 N1: drop the docstring sentence, or say what it means for
--json. - Keep the two halves consistent (shape-doctor.py: the members row calls a beside-the-holder repository the working clone on its project id alone, where the family's own verifier also requires the origin #146).
siblings.py::submodule_urlsis Tracking: setup, scaffold, family and the shared helpers, creating projects and families #459's half, owned by lane openRepoShape-5, in a pinned copy (FAMILY_COPIED_VERBATIM).- Both should read the file the same way: the reading above, mapped to
{path or name: url}. - Today they agree on L23 only by accident, because both truncate. They disagree on L22 and L25, and this change makes them agree.
- If this lands alone, they disagree on a url holding a line break until the holder's
siblings.pyis fixed and re-pinned. - So land both halves in the same release. Whichever lands second adds the parity test below.
- Both should read the file the same way: the reading above, mapped to
- Pinned shape copies: none in this half.
shape-doctor.pyis not one.
Tests:
- The corpus, in
tests/test_doctor_gitmodules_not_utf8.py, with theholderandmember_besidefixtures it already uses:- a section name holding a space, a dot, a quote and an
=; - a url holding each of
\x0b,\x0c,\x1c,\x1d,\x1e,\x85, U+2028 and U+2029; - a section name in Latin-1, under
LC_ALL=C.UTF-8and underLC_ALL=C(skipped where the locale is absent).
- a section name holding a space, a dot, a quote and an
- For each case:
mounted_fromequals git's owngit config --getreading of that section's url;submodule_confighas no''entry;- a clone of that url beside the holder is the working clone;
gitmodules_entrygives the same url.
section_url: extendtests/test_doctor_legs_members_next.py::test_section_url_reads_gits_listing_and_the_last_value_wins(:2005) with a--listlisting that has other sections in it.- Parity: the same corpus, read through the doctor's reader and through the holder's
siblings.submodule_urls, gives the same{path: url}.
From #460, #460 (comment) (L22, L23, L25)
From #461, #461 (comment) (R432 N1)
🤖 Generated with Claude Code
Activity
brettheap commentedon Oct 16, 2026
CLAIMED — lane openRepoShape-3, session b30e8b49-f249-4668-adb1-1dbfa93c09e1@Eagle, 2026-10-16T12:55:52Z, for #668
Logged in
lanes/log/openRepoShape-3.mdat87bf264669f3e830c1ff6042983d3eb7f4c71404.The three reads (lane-collision-protocol Rule 1):
shape-doctor.py: with no `.gitmodules` in the working tree, `gitmodul…
siblings.py: the printed move runs as typed past a taken staging name…