Repository navigation
Description
(lane openRepoShape-1, 2026-11-10T10:43:48Z)
Found by: r1300a, lane 1's reviewer of PR #1300 (for #1283), F1 of issuecomment-6764753070; measured again by w1300r, lane 1's writer of #1300's first review round. r1300a found that once #1300 compares HEAD's ref with the tracking branch as git's bytes read back (_branch_ref), _folded_twin is the one check in step (a) that still compares it with the manifest's text, and that no open issue names its misses, which #1283's fourth "Done when" box asks for. Lane 1 ruled that #1300 leaves _folded_twin as it is, since what a case twin is for a name that is not UTF-8 is a question of its own. This is that question's issue. It follows #1283.
Lane 3 places this issue, and it has no milestone here: v1.2.1 is frozen. It is in the area of #896 and #962 (case twins, both closed), of #1283 and #1300 (a name the locale reads back as other text), and of #704 and #715 (a branch that is not UTF-8).
This body is ASCII, so each non-ASCII character is written as its code point, and a printed escape is written with a backslash. <ff> and <c3 a9> name bytes. In the quoted lines, <U+2014>, <U+00FF>, <U+00E9>, <U+00C3> and <U+00A9> each stand for that one character.
What is wrong
_folded_twin in templates/assembly-root/scripts/bootstrap.py asks whether HEAD's ref is a TWIN of the tracking branch: a branch under refs/heads/ whose name is the branch's under _fold (NFC, then str.casefold()) and not byte for byte (#896, #962). It compares HEAD's ref, as _head_of decodes it (os.fsdecode of git's bytes), with the manifest's text: held != branch and _fold(held) == _fold(branch). The two sides were decoded differently. Where the locale reads a twin's bytes as other text than the manifest's surrogates, the twin is missed:
- Under Latin-1,
TB<ff>xfortracking_branch: "tb\udcffx"._head_ofreadsTB<ff>xasTBU+00FFx, which folds totbU+00FFx. The manifest'stb\udcffx(U+DCFF, repo_shape.py's YAML reader: Unicode spaces are stripped from text YAML keeps, the empty block key andk: {?: 1}still read, and three texts about the reader are one word out of date (what #635 left) #715's spelling of the byte 0xFF) folds to itself. UTF-8 and ASCII read the byte as U+DCFF and find the twin. - Under UTF-8,
CAF<c3 a9>fortracking_branch: "caf\udcc3\udca9"._head_ofreadsCAF<c3 a9>asCAFU+00E9. The manifest spells the same two bytes as U+DCC3 U+DCA9. ASCII reads them as U+DCC3 U+DCA9 and finds the twin. Latin-1 misses it too (CAFU+00C3 U+00A9).
_folded_spelling asks _folded_twin of every branch under refs/heads/ before checkout -b, so it misses the same twins with HEAD elsewhere (measured below, with HEAD detached at the pin).
What the miss does. Step (a) makes the tracking branch with checkout -b beside the twin and says created. Where the twin is found, it says the leg has a twin, leaves the leg as it is, and gives the rename. On a disk that folds case (macOS APFS, Windows NTFS by default), refs/heads/CAF<c3 a9> and refs/heads/caf<c3 a9> are one loose file, which is #896's harm. Whether TB<ff>x and tb<ff>x are one file on any disk is part of the question below: APFS refuses a name that is not UTF-8 (w1283a's reading in #1300, not measured). Every run ends bootstrap ok, exit 0.
The tracking branch itself is never a false twin. HEAD on tb<ff>x for tb\udcffx, and on caf<c3 a9> for caf\udcc3\udca9, is no twin under UTF-8, Latin-1 and ASCII (measured, below).
The miss is not new. Main gives the same 15 twin answers in process (below). End to end, main misses the same twins and makes the branch beside them too. It then says could not create branch over it, #1283's false line, which #1300 turns into created. Git's refs and HEAD after each run are the same on main and at #1300's head.
What was measured
Every run below used Python 3.12.3 and git 2.43.0 on Linux, in lane 1's probe environment: a stub gh first on PATH, GIT_CONFIG_GLOBAL=/dev/null and GIT_SSH_COMMAND=false.
- Latin-1 is built as adopt-project.py: under a one-byte locale such as Latin-1, a clone
checkmakes again for a plan's clone record that neither spelling names is compared with both, so it is kept and the next run reads it rather than cloning again (#1112) #1153's test builds it:localedef -c, thenLOCPATH,LC_ALL=en_US.ISO-8859-1andPYTHONUTF8=0. The child reportsiso8859-1. - UTF-8 is
LC_ALL=C.UTF-8. - ASCII is
LC_ALL=C PYTHONUTF8=0 PYTHONCOERCECLOCALE=0, and the child reportsascii.
The trees:
- main:
b607223b4a1c48ba6bdae9b02c16e7435592bd05. Itstemplates/assembly-root/scripts/bootstrap.pyis blob41c2eb42, the same as at5f06c3eb, the main assembly-root bootstrap.py: step (a) asks whether HEAD is on the tracking branch by the bytes git was handed, so under a Latin-1 localetb\udcffxis said created, then on, where it saidcould not create branchandgit refused(#1283) #1300 was built on. - assembly-root bootstrap.py: step (a) asks whether HEAD is on the tracking branch by the bytes git was handed, so under a Latin-1 locale
tb\udcffxis said created, then on, where it saidcould not create branchandgit refused(#1283) #1300's head:cb9ed8067c5441b3fea110a7ff9dd1985bbc74ef, blob8e0f76c7._folded_twin,_fold,_headsand_head_of's decoding are the same as on main.
In process
r1300a's twin.py loads the file and hands _folded_twin HEAD's ref as _head_of decodes it (os.fsdecode(b"refs/heads/" + raw)), with the manifest's branch, in a child under each locale. At #1300's head:
utf-8: b'tb\xffx' vs 'tb\udcffx' twin=False; b'TB\xffx' vs 'tb\udcffx' twin=True; b'caf\xc3\xa9' vs 'caf\udcc3\udca9' twin=False; b'CAF\xc3\xa9' vs 'caf\udcc3\udca9' twin=False; b'Main' vs 'main' twin=True;
iso8859-1: b'tb\xffx' vs 'tb\udcffx' twin=False; b'TB\xffx' vs 'tb\udcffx' twin=False; b'caf\xc3\xa9' vs 'caf\udcc3\udca9' twin=False; b'CAF\xc3\xa9' vs 'caf\udcc3\udca9' twin=False; b'Main' vs 'main' twin=True;
ascii: b'tb\xffx' vs 'tb\udcffx' twin=False; b'TB\xffx' vs 'tb\udcffx' twin=True; b'caf\xc3\xa9' vs 'caf\udcc3\udca9' twin=False; b'CAF\xc3\xa9' vs 'caf\udcc3\udca9' twin=True; b'Main' vs 'main' twin=True;
On main's blob the 15 answers are the same, line for line.
End to end
A probe built one scaffold's recursive clone. For each case it:
- copied the clone and set
tracking_branch; - put the
specleg on the twin at the pin (git checkout -b <the twin's bytes> <pin>), or made the twin a branch at the pin with HEAD detached there, the tracking branch itself absent; - ran
scripts/bootstrap.py --skip-validatorsonce, withPYTHONIOENCODING=utf-8:strict.
These are step (a)'s lines for spec, at #1300's head; the code leg says created in every case.
HEAD on TB<ff>x, tracking_branch: "tb\udcffx". Under UTF-8 and under ASCII, the same three lines:
[spec] spec: branch tb\udcffx does not exist (the pin is 5985a5dad55d), and the checkout is on TB\udcffx, which differs from tb\udcffx only in case
a disk that folds case (macOS, Windows) reads TB\udcffx and tb\udcffx as one branch, so making tb\udcffx could hide the commits a branch spelled like tb\udcffx holds behind the new ref; the leg is left as it is
rename TB\udcffx to a name that differs from tb\udcffx by more than case, its commits staying on it: `git -C spec branch -m "$(printf -- 'TB\377x')" "$(printf -- 'TB\377x-kept')"`, and run bootstrap again.
HEAD stays on TB<ff>x, and the leg's branches are TB<ff>x and main. Under Latin-1:
[spec] spec: branch tb\udcffx created at 5985a5dad55d <U+2014> at the pin
the leg was on TB<U+00FF>x, which keeps its commits; it is on tb\udcffx now
HEAD is on tb<ff>x, beside TB<ff>x.
HEAD on CAF<c3 a9>, tracking_branch: "caf\udcc3\udca9".
- Under ASCII: the three twin lines, for
CAF\udcc3\udca9, with the rename word"$(printf -- 'CAF\303\251')". HEAD stays onCAF<c3 a9>. - Under UTF-8:
branch caf\udcc3\udca9 created at 5985a5dad55d <U+2014> at the pin, thenthe leg was on CAF<U+00E9>, which keeps its commits; it is on caf\udcc3\udca9 now. HEAD is oncaf<c3 a9>, besideCAF<c3 a9>. - Under Latin-1: the same two lines, with
the leg was on CAF<U+00C3><U+00A9>.
HEAD detached at the pin, the twin a branch at the pin (_folded_spelling).
tb\udcffxunder UTF-8:branch tb\udcffx does not exist (the pin is 00fe64962ab1), and the leg has the branch TB\udcffx, which differs from tb\udcffx only in case, then the same two lines as above. The leg stays detached.tb\udcffxunder Latin-1:branch tb\udcffx created at 00fe64962ab1 <U+2014> at the pin. HEAD is ontb<ff>x, besideTB<ff>x.caf\udcc3\udca9under ASCII:... and the leg has the branch CAF\udcc3\udca9, which differs from caf\udcc3\udca9 only in case, and the leg stays detached.caf\udcc3\udca9under UTF-8:created, and HEAD is oncaf<c3 a9>, besideCAF<c3 a9>.
On main (blob 41c2eb42), HEAD on the twin:
tb\udcffxunder UTF-8, andcaf\udcc3\udca9under ASCII, give the same three twin lines as at assembly-root bootstrap.py: step (a) asks whether HEAD is on the tracking branch by the bytes git was handed, so under a Latin-1 localetb\udcffxis said created, then on, where it saidcould not create branchandgit refused(#1283) #1300's head.tb\udcffxunder Latin-1 misses the twin, makestb<ff>xbeside it and sayscould not create branch 'tb\udcffx' at the pin 5985a5dad55d; leaving it on TB<U+00FF>x, over`git checkout -b` exited 0.caf\udcc3\udca9under UTF-8 does the same and says... leaving it on CAF<U+00E9>.- HEAD and the branches after each run are what they are at assembly-root bootstrap.py: step (a) asks whether HEAD is on the tracking branch by the bytes git was handed, so under a Latin-1 locale
tb\udcffxis said created, then on, where it saidcould not create branchandgit refused(#1283) #1300's head.
Every run exited 0.
The question a fix must settle
What is a case twin of a branch whose name is not UTF-8? Case twins were decided in #896 (case) and #962 (NFC and NFD, and every branch with HEAD elsewhere), both closed. Neither met a name the locale reads back as other text than the manifest's surrogates.
w1283a's Latin-1 objection, from #1300. One way out is to fold the branch as git's bytes read back, _branch_ref(branch)[len("refs/heads/"):], as #1300 compares HEAD's ref with it. That finds both misses above. But it changes what a twin is under Latin-1: the bytes 0xC4 and 0xE4 read back as U+00C4 and U+00E4, which fold alike. So tb<c4>x and tb<e4>x would become twins under Latin-1, where UTF-8 and ASCII read each byte as a surrogate and call them none. Computed in process at #1300's head (fold_c4.py, w1300r's):
utf-8 read back: 'tb\udcc4x' 'tb\udce4x' folded equal: False | _folded_twin(HEAD on tb<e4>x, branch tb\udcc4x): False
iso8859-1 read back: 'tb\xc4x' 'tb\xe4x' folded equal: True | _folded_twin(HEAD on tb<e4>x, branch tb\udcc4x): False
ascii read back: 'tb\udcc4x' 'tb\udce4x' folded equal: False | _folded_twin(HEAD on tb<e4>x, branch tb\udcc4x): False
Today all three locales say no twin there. The one who takes this decides whether such a pair is a twin, which depends on whether any disk that folds case holds the two as one file.
Another way out, the filer's, computed and not tried in the file. Fold both sides as git's bytes decoded by ONE codec, UTF-8 with surrogateescape: HEAD's raw ref, and _handed_to_git(branch). fold_alt.py (w1300r's) computes it at #1300's head with the file's own _fold and _handed_to_git. The line is the same under Latin-1 and ASCII but for the codec's name:
utf-8: b'tb\xffx' vs 'tb\udcffx' alt=False; b'TB\xffx' vs 'tb\udcffx' alt=True; b'caf\xc3\xa9' vs 'caf\udcc3\udca9' alt=False; b'CAF\xc3\xa9' vs 'caf\udcc3\udca9' alt=True; b'tb\xe4x' vs 'tb\udcc4x' alt=False; b'Main' vs 'main' alt=True;
So both misses are found in every locale, the tracking branch itself and tb<e4>x for tb\udcc4x stay no twins, and Main for main stays one. _folded_spelling reads branch names through _heads, which decodes them, so it would need the raw names as well.
Done when
- What a case twin is for a branch whose name is not UTF-8 is decided, the bytes 0xC4 and 0xE4 under Latin-1 included, and
_folded_twin's docstring says it. - Under that decision, end to end under Latin-1 (built as adopt-project.py: under a one-byte locale such as Latin-1, a clone
checkmakes again for a plan's clone record that neither spelling names is compared with both, so it is kept and the next run reads it rather than cloning again (#1112) #1153's test builds one), UTF-8 and ASCII, a leg onTB<ff>xwithtracking_branch: "tb\udcffx", and a leg onCAF<c3 a9>withtracking_branch: "caf\udcc3\udca9", each get one answer in every locale: the twin lines with the leg left as it is, orcreated, as decided. - The same holds with HEAD detached at the pin beside the twin (
_folded_spelling). - HEAD on the tracking branch itself (
tb<ff>x,caf<c3 a9>) is still no twin in every locale, and bootstrap.py: on a disk that folds case, a leg onMainwhose tracking branchmainis behind the pin is moved under its own HEAD, and bootstrap saysit is on main nowover an index that undoes the pin #896'sMainformainand the assembly root's bootstrap.py:create_at_pinstill hides a branch's commits behind a new loose ref when HEAD is detached or a third spelling is packed, and_folded_twindoes not fold NFC and NFD #962's NFC and NFD twins keep their lines under UTF-8. -
_branch_ref's docstring no longer names_folded_twinas the one check that still compares text, or says why it still does. - Rows hold each case in a child under the locale it names, as
tests/test_bootstrap_branch_one_byte_locale.pydoes.
See #1283, #1300, #896, #962, #704, #715, #1153 and #1259.
Lane: openreposhape-1 (openRepoShape-1)
Activity
brettheap commentedon Nov 10, 2026
CLAIMED — lane openRepoShape-1, session 300f8f46-004a-4e72-8587-4f192be2e108@Eagle, 2026-11-10T12:19:45Z, for #1306
Logged in
lanes/log/openRepoShape-1.mdat868016982f842cb7f00d9cab02c8b9d742913ab7.The three reads (lane-collision-protocol Rule 1):
assembly-root bootstrap.py: `_folded_twin` also reads git's bytes as …
tests/test_bootstrap_branch_one_byte_locale.py: HEAD on `tb84x` is a …
tests/test_bootstrap_branch_one_byte_locale.py: the `xutftowcsn` row …