Repository navigation
adopt-project.py check passes a source whose tree holds a symlink whose target begins with a NUL byte (\0spec.md, a 120000 blob of size 8), so with symlinks on execute creates both leg repositories and then fails cloning the source, exit 2 with nothing on stderr, and #303's plan-empty-symlink, which tests the blob's size, does not find it #388
Description
Lane: openreposhape-5 (openRepoShape-5)
(lane openRepoShape-5, 2026-10-12T15:17:31Z)
Found by lane 5's review of fix/adopt-check-link-and-manifest at 69c54c9 (the fix for #303 and #305), its N6. Pre-existing on origin/main 161c6c9 (adopt-project.py is the same file at 0f67f7b), wherever the link sits in the tree. It is outside #303's literal scope, the empty blob, and the review's brief was to attack that fix. Not claimed.
What is wrong. #303's failure has a second spelling that its fix does not see. A tracked symlink whose blob begins with a NUL byte is not the empty blob (\0spec.md is 8 bytes), but Linux reads a leading NUL as an empty target, so symlink(2) fails with ENOENT exactly as it does for the empty blob. plan and check know a link only by its mode and its size (Source.tree, adopt-project.py:750-763, from git ls-tree -r -l) and never read its target, so check says plan ok. What execute does next is #303's:
- With symlinks on, it creates both leg repositories (
_create_leg_remotes, called at:4077) and then fails in its first clone of the source (_extract_leg, thegit cloneat:3337), whatever the plan answers for the link,dropincluded._build_the_legsswallowsCommandFailed(:3859-3860, adopt-project.pyexecuteexits 2 with nothing on stderr whengit filter-repofails, after both leg remotes exist:_build_the_legsswallowsCommandFailedon the premise thatrunalready reported it, andrunonly raises #171), so the run ends at:4091-4092with exit 2, nothing on stderr and two empty leg repositories left behind. - With
core.symlinks=false, it saysadoption verifiedover a spec leg that no clone with symlinks on can check out, and the assembly's recursive clone exits 1.
The fix for #303 (head 69c54c9, not merged when this was filed) tests mode == SYMLINK_MODE and not size (empty_symlinks, adopt-project.py:2835-2839 there). A NUL-led target has size 1 or more, so on that head plan prints no NOTE, check exits 0 and execute fails as below.
SHAPE=<openRepoShape checkout> # with git-filter-repo on PATH
# Every repository is local (--local-remote-dir), so no GitHub is reached. Keep the real `gh` out of reach anyway:
STUB=$(mktemp -d); printf '#!/bin/sh\nexit 1\n' > "$STUB/gh"; chmod +x "$STUB/gh"
export PATH="$STUB:$PATH" GH_TOKEN=bogus GH_CONFIG_DIR=$(mktemp -d)
export GIT_AUTHOR_NAME=T [email protected] GIT_COMMITTER_NAME=T [email protected]
LINK=docs/odd-link
TMP=$(mktemp -d)
git init -q -b main "$TMP/Thing" && cd "$TMP/Thing" || exit 1
mkdir src docs && printf 'print(1)\n' > src/app.py && printf '# Spec\n' > docs/spec.md
printf '# Thing\n' > README.md && git add -A
target=$(printf '\000spec.md' | git hash-object -w --stdin)
git update-index --add --cacheinfo "120000,$target,$LINK" # a symlink whose target blob begins with NUL
git commit -qm init && git ls-tree -r -l HEAD -- "$LINK"
python3 "$SHAPE/adopt-project.py" plan --source "$TMP/Thing" --project Northwind --org testorg \
--elected-by 'T H' --elected-on 2026-09-02 --out "$TMP/plan.yaml" >/dev/null
echo "plan exit $?"
python3 "$SHAPE/adopt-project.py" check --plan "$TMP/plan.yaml" | tail -1
python3 "$SHAPE/adopt-project.py" execute --plan "$TMP/plan.yaml" --yes \
--local-remote-dir "$TMP/remotes" --work-dir "$TMP/work" > "$TMP/out" 2> "$TMP/err"
echo "execute exit $?; stdout:"
cat "$TMP/out"
echo "stderr: $(wc -c < "$TMP/err") bytes"
echo "leg repositories left: $(ls "$TMP/remotes" | tr '\n' ' ')"
git clone -q "$TMP/Thing" "$TMP/any-clone" 2> "$TMP/clone-err"; echo "a plain git clone of the source: exit $?"; head -2 "$TMP/clone-err"Observed on origin/main 161c6c9 (Linux, git 2.43.0, Python 3.12.3; <T> is the temporary directory), and byte-identical on 69c54c9:
120000 blob da51ee712ecf519313363bb25342bb6dc80f4b8d 8 docs/odd-link
plan exit 0
plan ok
execute exit 2; stdout:
topics skipped for local remotes
creating the leg repositories
bare <T>/remotes/Northwind-spec.git
bare <T>/remotes/Northwind-code.git
stderr: 0 bytes
leg repositories left: Northwind-code.git Northwind-spec.git
a plain git clone of the source: exit 128
error: unable to create symlink docs/odd-link: No such file or directory
fatal: unable to checkout working tree
With core.symlinks=false for the whole adoption, then a clone with symlinks on, as #303's second script does (the same source, then):
( # the adoption runs where git checks a symlink out as a plain file
export GIT_CONFIG_COUNT=1 GIT_CONFIG_KEY_0=core.symlinks GIT_CONFIG_VALUE_0=false
python3 "$SHAPE/adopt-project.py" plan --source "$TMP/Thing" --project Northwind --org testorg \
--elected-by 'T H' --elected-on 2026-09-02 --out "$TMP/plan.yaml" >/dev/null
python3 "$SHAPE/adopt-project.py" check --plan "$TMP/plan.yaml" | tail -1
python3 "$SHAPE/adopt-project.py" execute --plan "$TMP/plan.yaml" --yes \
--local-remote-dir "$TMP/remotes" --work-dir "$TMP/work" > "$TMP/out" 2> "$TMP/err"
echo "execute exit $?: $(grep '^adoption verified' "$TMP/out")"
)
echo "the spec leg holds: $(git -C "$TMP/remotes/Northwind-spec.git" ls-tree -r main -- "$LINK")"
git clone -q "$TMP/remotes/Northwind-spec.git" "$TMP/spec-clone" 2> "$TMP/spec-err"
echo "a clone of the spec leg: exit $?"; head -2 "$TMP/spec-err"
git -c protocol.file.allow=always clone -q --recurse-submodules -b adopt/three-repo-shape \
"$TMP/Thing" "$TMP/assembly" > "$TMP/rec" 2>&1
echo "the assembly's recursive clone: exit $?"
grep -E '^(error|fatal)' "$TMP/rec" | sed -E "s#$TMP#<T>#g; s#'[0-9a-f]{40}'#'<spec commit>'#"Observed on the same trees:
plan ok
execute exit 0: adoption verified: every source path is in exactly one place
the spec leg holds: 120000 blob da51ee712ecf519313363bb25342bb6dc80f4b8d docs/odd-link
a clone of the spec leg: exit 128
error: unable to create symlink docs/odd-link: No such file or directory
fatal: unable to checkout working tree
the assembly's recursive clone: exit 1
error: unable to create symlink docs/odd-link: No such file or directory
fatal: Unable to checkout '<spec commit>' in submodule path 'spec'
Measured with the same script and other targets, symlinks on, on origin/main 161c6c9 and on 69c54c9 (the two agree on every row but the empty one):
| the link's blob | check |
execute |
a plain clone of the source |
|---|---|---|---|
spec.md (control) |
plan ok |
exit 0, adoption verified |
exit 0 |
| empty (#303) | plan ok on main; plan-empty-symlink on 69c54c9 |
on main exit 2, 0 bytes of stderr, both legs left; on 69c54c9 refused, no leg | exit 128, unable to create symlink ...: No such file or directory |
\0spec.md |
plan ok |
exit 2, 0 bytes of stderr, both legs left | exit 128, the same error |
spec\0.md (a NUL later) |
plan ok |
exit 2, 431 bytes of stderr, both legs left (see below) | exit 0 |
5000 a |
plan ok |
exit 2, 0 bytes of stderr, both legs left | exit 128, unable to create symlink ...: File name too long |
Why it matters.
- With symlinks on, no adoption of such a source can succeed, whatever the plan answers: the first clone fails. Every attempt creates both leg repositories first. Against GitHub that is two real repositories per attempt, and the next attempt meets them.
- On main nothing is printed about why. Once adopt-project.py
executeexits 2 with nothing on stderr whengit filter-repofails, after both leg remotes exist:_build_the_legsswallowsCommandFailedon the premise thatrunalready reported it, andrunonly raises #171's fix (lane 1's PR adopt-project.py:executeprints the command and its stderr when a leg cannot be built, so agit filter-repothat fails after both leg remotes exist no longer exits 2 with an empty stderr (#171) #184) lands, the run says why, but the legs are still made first. - With
core.symlinks=false, the run that verifies is the worse outcome: itsadoption verifiedandNEXT:hand over a repository that no clone with symlinks on can check out. - It is rare. A real checkout cannot hold such a link, so one comes from
git update-index --cacheinfo,git hash-object, an import stream or another tool's commit. The cause is in the source, readable from its tree before anything exists.
Where (origin/main 161c6c9):
adopt-project.py:750-763,Source.tree:(path, mode, oid, size)per entry. It is the only thingplanandcheckread of a link.adopt-project.py:3697,_refuse_what_check_finds, called at:4066:execute's refusal of whatcheckfinds, before_create_leg_remotes(:4077).adopt-project.py:3327-3337,_extract_leg;:3836-3860,_build_the_legs;:4089-4092,cmd_executereturning 2 when it getsNone.- On 69c54c9:
adopt-project.py:2835-2839,empty_symlinks, the size test;:2884-2892,_source_path_findings, where the finding is composed.
What would fix it.
planandcheckread each120000target (onegit cat-file --batchover the object idsSource.tree()already lists, in bytes) and report a link whose targetsymlink(2)reads as empty: one that begins with NUL. The remediation is adopt-project.pycheckpasses a source whose tree holds a symlink with an empty target, so with symlinks onexecutecreates both leg repositories and then fails cloning the source (on main with exit 2 and nothing on stderr, #171), and withcore.symlinks=falseit saysadoption verifiedover a leg or root that no clone with symlinks on can check out #303's: give the link a target in the source, or remove it there, commit, and re-runplan.executerefuses it before any leg exists, through adopt-project.pyexecuterefuses onlyplan-unresolvedandplan-stale, so a plancheckrejects as uncovered or with a bad leg creates and pushes both legs before it fails verification #168's list, as it refusesplan-empty-symlink.- The decisions are the author's: whether it is
plan-empty-symlinkwith its sentence widened (it says "empty", and this blob is not) or a sibling finding; and whether the target is read for every link or only for those whose size is not 0.
How to test. In tests/test_adopt_empty_symlinks.py on the #303 branch, whose put_link(repo, path, target: bytes) already builds a link in the index from bytes written to git hash-object on stdin, so it runs on Windows:
- (a) a link at
docs/odd-linkwith targetb"\0spec.md":checkexits 1 with a finding naming it, andexecuterefuses before any leg exists (the remotes directory holds none); - (b) the same with target
b"spec.md"(control):checksaysplan ok; - (c)
core.symlinks=falsefor the run changes neither answer.
Reverting the fix fails (a). A test must pin neitherspec\0.mdnor a long target (see Not in this issue).
Not in this issue.
- A NUL later in the target (
spec\0.md). It is a different failure: the clone succeeds and the link reads back asspec, which is not the recorded blob, soexecutedies later atgit --literal-pathspecs rm -r -q -- docsin its work clone,error: the following file has local modifications: docs/odd-link, with both legs made. Same class as adopt-project.pycheckpasses a source whose tree holds a symlink with an empty target, so with symlinks onexecutecreates both leg repositories and then fails cloning the source (on main with exit 2 and nothing on stderr, #171), and withcore.symlinks=falseit saysadoption verifiedover a leg or root that no clone with symlinks on can check out #303, an entry git cannot check out as recorded whereexecuteruns; not this change. - A target longer than the platform allows (5000 bytes:
File name too long, the same symptom as this issue). The wider question, which adopt-project.pycheckpasses a source whose tree holds a symlink with an empty target, so with symlinks onexecutecreates both leg repositories and then fails cloning the source (on main with exit 2 and nothing on stderr, #171), and withcore.symlinks=falseit saysadoption verifiedover a leg or root that no clone with symlinks on can check out #303's fix leaves as a note: an entry git cannot check out whereexecuteruns is better found before the legs than by the first clone. If the fix for this issue reads every target anyway, the length test is the author's to add or to leave for that question. - Making
dropa fix: with symlinks on the clones still check the link out, as adopt-project.pycheckpasses a source whose tree holds a symlink with an empty target, so with symlinks onexecutecreates both leg repositories and then fails cloning the source (on main with exit 2 and nothing on stderr, #171), and withcore.symlinks=falseit saysadoption verifiedover a leg or root that no clone with symlinks on can check out #303 says. - adopt-project.py
executeexits 2 with nothing on stderr whengit filter-repofails, after both leg remotes exist:_build_the_legsswallowsCommandFailedon the premise thatrunalready reported it, andrunonly raises #171's silence (PR adopt-project.py:executeprints the command and its stderr when a leg cannot be built, so agit filter-repothat fails after both leg remotes exist no longer exits 2 with an empty stderr (#171) #184), and the order ofexecute(legs made before the first clone).
Related. #303, whose plan-empty-symlink this extends. #171 and PR #184: the silence. #183: lane 1's plan-root-symlink also reports an empty link kept at or above a shape path, and would meet a NUL-led one only through whatever reads its target. #168: execute refuses what check finds.
Activity
adopt-project.py: `check` finds, and `execute` refuses before any leg…
brettheap commentedon Oct 16, 2026
CLAIMED — lane openRepoShape-1, session 300f8f46-004a-4e72-8587-4f192be2e108@Eagle, 2026-10-16T11:31:43Z, for #388
Logged in
lanes/log/openRepoShape-1.mdat9d07ed25076645a0f809253a3110f0cc492ef640.The three reads (lane-collision-protocol Rule 1):
Merge #748's final head 8368d1f and main fa04d2c into fix/758-git-com…
tests/test_doctor_legs_members_next.py and 24 other files: tests appe…