Skip to content

adopt-project.py: execute unsets the leg clone's remote.origin.url before git filter-repo, so under a Latin-1 locale a source under a directory named with the byte 0xE9 is extracted, where filter-repo died printing that url as U+FFFD, and every branch of the source is still rewritten as before (#1247) - #1251

Merged
brettheap merged 3 commits into
mainfrom
fix/1247-filter-repo-origin-url
Nov 8, 2026

Conversation

@brettheap

@brettheap brettheap commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

Closes #1247

(lane openRepoShape-4, 2026-11-08T14:44:07Z) Lane 3 places this PR; it carries no milestone here.

Head abeac66d is a fix round for RV1251's review of 825923c7 (#1251 (comment)): one SHOULD and two NITs, set out under "Review round 1" below. The sections after that describe this head.

_extract_leg (adopt-project.py) now unsets the leg clone's remote.origin.url, in the clone's own config file (--file <work>/.git/config), right after its checkout -B and before git filter-repo runs. filter-repo then prints no url, so a Latin-1 stdout has no U+FFFD to choke on, and it still turns every remote-tracking branch into a branch first, so the legs are the ones main makes.

The defect, reproduced on main

creating the leg repositories
  bare  .../remotes/Northwind-spec.git
  bare  .../remotes/Northwind-code.git
REFUSED extracting the spec leg. THE EXACT COMMAND WAS:
    git filter-repo --paths-from-file .../work/spec-paths.txt --force
    (in .../work/Northwind-spec)
    exit 1
--- output ---
Traceback (most recent call last):
  File ".../frvenv/bin/git-filter-repo", line 8, in <module>
    sys.exit(main())
  File ".../git_filter_repo.py", line 4973, in main
    filter.run()
  File ".../git_filter_repo.py", line 4878, in run
    self._migrate_origin_to_heads()
  File ".../git_filter_repo.py", line 4462, in _migrate_origin_to_heads
    print(m)
UnicodeEncodeError: 'latin-1' codec can't encode character '\ufffd' in position 237: ordinal not in range(256)
--- end output ---

Both bare leg repositories were left behind. So the defect does not need a -E launcher: a person in a Latin-1 locale sets no PYTHONIOENCODING, and pip's launcher fails as well.

The existing row, test_adopt_template_values.py::test_a_utf8_source_directory_still_adopts_with_local_remotes, under Latin-1 on main:

The fix, and the two candidates measured first

Candidate 1 in #1247, git remote remove origin before filter-repo, changes what the legs hold. It is rejected.

  • git remote remove deletes refs/remotes/origin/* with the remote. filter-repo then no longer makes the source's other branches into branches, and never rewrites them.
  • Measured with execute on main and on candidate 1, over two ASCII sources with fixed dates. For each leg's bare repository the probe compared: every ref, every commit with its tree, parents and full message, and every reachable object.
    • The standard source (make_source_repo, one branch): identical.
    • A source with a release branch whose commit R changes specs/001-feature/tasks.md, no tag reaching it, and on main a git cherry-pick -x R: the spec leg's tip differs, 0316169e on main against 82176493 on candidate 1, with the same tree 9ef5b676. On main its message reads (cherry picked from commit 407d03a0...), R as rewritten. Under candidate 1 it reads (cherry picked from commit 30e9dd30...), R's id in the source.
  • It also changes behaviour that check describes. As a mutant, it fails the existing test_adopt_split_branch.py::test_the_extraction_stops_at_a_source_branch_in_its_way (both rows, DID NOT RAISE CommandFailed). With it, a source branch in git's way no longer stops the extraction.

Candidate 2, LC_ALL=C.UTF-8 for the child, depends on the host.

  • Measured here: under python3 -E, a pipe's encoding is utf-8 under LC_ALL=C.UTF-8. It is also utf-8 under C, POSIX and a locale name that does not exist, because CPython falls back to C and turns on its UTF-8 mode.
  • But it hands the child a locale by name and leans on that interpreter behaviour. It changes the locale of every git command filter-repo starts. And on Windows, LC_ALL does not set a pipe's encoding (read, not run).
  • No PYTHON* variable is a cure, because a -E launcher drops it.

What this PR does: unset the url only (git config --file <work>/.git/config --unset remote.origin.url). It depends on no locale. It names the clone's own config file, so GIT_CONFIG in the environment cannot redirect it to a file of the person's (RV1251's SHOULD-1, below). It goes on from a clone that has no url to unset, and from no other failure (NIT-1, below).

  • filter-repo's _migrate_origin_to_heads (2.47.0) turns refs/remotes/origin/* into refs/heads/* first. Then it returns when remote.origin.url is not in the config, before the NOTICE that printed the url and before its own git remote rm origin.
  • The legs are byte-identical to main's in both probes above, the cherry-pick source included (diff of the dumps: empty).
  • What stays in each work clone (measured on this head, a plain execute): the url-less [remote "origin"] with its fetch refspec +refs/heads/*:refs/remotes/origin/*, and branch.main.remote = origin and branch.main.merge = refs/heads/main. Nothing reads any of it. _push_the_leg pushes to the leg's url, and _mount_the_legs mounts the clone by its path. RV1251 measured that the mounted submodules hash the same as main's.
  • The change is one run in _extract_leg (now with a try), with a comment. No pinned or template copy of adopt-project.py exists, and no document describes this step.

Review round 1 (RV1251 at 825923c7)

SHOULD-1, fixed: the unset named no config file. GIT_CONFIG in the environment (a legacy variable git still reads) names the file a bare git config writes.

  • Reproduced with GIT_CONFIG naming a file that holds [remote "origin"] url = ... and the standard source, in execute:
    • main: exit 0, adoption verified, the file unchanged.
    • 825923c7: exit 2, REFUSED extracting the spec leg, both bare legs made and nothing pushed, and the file empty. The first leg's unset took the only key out of it, and filter-repo, reading that empty file as the config, died with a ValueError in get_config_settings. (RV1251's file ended in an unset exit 5 instead.)
    • this head: exit 0, adoption verified, the file byte for byte as it was.
  • Fix: run(["git", GIT_CONFIG, "--file", str(work / ".git" / "config"), "--unset", "remote.origin.url"], cwd=work). --local is no way round it: with GIT_CONFIG set, git 2.43 exits 129 (only one config file at a time).
  • work / ".git" is a directory wherever execute reaches the clone:
    • the clone is made by one git clone -q <source> <work>, and work is work_root / <name>, where work_root is os.path.realpath(--work-dir) or a tempfile.mkdtemp folder (_work_root): an absolute path;
    • an exported GIT_DIR does not move a clone (measured: the clone has its own .git);
    • an exported GIT_WORK_TREE does make the clone another shape (the git dir is work itself), but execute stops on it first, on main and on this head alike, at the legs' git init --bare (REFUSED a git or gh command failed);
    • a path whose directory is not there gives exit 255 (could not lock config file ... No such file or directory), which is refused.
  • Not changed: filter-repo's own git config --list also reads the file GIT_CONFIG names (the ValueError above came from it), so under GIT_CONFIG it sees that file's settings, as on main. On this head the run ends adoption verified with the legs main makes.

NIT-1, handled: a clone with no origin url. A global clone.defaultRemoteName = upstream gives the clone a remote that is not origin, so git config --unset remote.origin.url has no key and exits 5 (measured, git 2.43). It can happen.

  • Before: main fails at mounting the legs (No such remote 'origin'), after both legs are pushed. 825923c7 failed earlier, at the unset (exit 5, an empty output block), with nothing pushed.
  • Now: _extract_leg goes on from exit 5 and from no other exit (GIT_CONFIG_KEY_ABSENT = 5). The run fails where main fails, not earlier and not worse. Any other exit of the unset (255 for a file git cannot lock, 129 for a usage it refuses) is refused as any failed command is.
  • Not mended here: clone.defaultRemoteName itself. execute fails on it on main too. It is a follow-up for its own issue.
  • Exit 5 also covers a config with more than one remote.origin.url (measured); that too goes on, as main does.

NIT-2, corrected in this body: the claim that the fix "depends on no locale and no variable" (it now names its config file, so GIT_CONFIG cannot redirect it); the work clone's leftovers, now listed under "What stays in each work clone" (the url-less [remote "origin"], branch.main.remote and branch.main.merge); and the note that #1141 conflicts, dropped: it merges clean at 0b8fb320.

Rows

tests/test_adopt_filter_repo_origin_url.py, new, five rows:

  • test_filter_repo_starts_with_no_origin_url_and_every_branch (any locale). _extract_leg itself runs over an ASCII source with a second branch, with run spied at the git filter-repo call. When filter-repo starts, the clone has no remote.origin.url and still has refs/remotes/origin/main and refs/remotes/origin/beside. filter-repo's output holds neither Removing 'origin' remote nor the source path. Afterwards the clone has refs/heads/beside, and the leg holds the clone's HEAD.
  • test_execute_adopts_a_source_named_in_latin1_under_latin1 (Latin-1). It runs plan, check and execute --local-remote-dir for adopt-project.py: under a one-byte locale such as Latin-1, execute stops extracting the spec leg of a source whose path holds U+00E9, because git filter-repo prints the clone's origin url as U+FFFD to a stdout that cannot hold it #1247's source (a directory caf plus the byte 0xE9) in a Latin-1 locale the test builds as adopt-project.py: under a one-byte locale such as Latin-1, check reads a plan written in UTF-8 whose source is there, asking the plan's UTF-8 bytes where the spelling as written names nothing, rather than refusing plan-source-gone (#1078) #1106 builds one. No PYTHON* variable is set except PYTHONUTF8=0. It asserts no traceback, check exit 0, execute exit 0 and adoption verified.
    • It skips, by name and with localedef's words, where no Latin-1 locale can be built, and on Windows. It also skips where a name that is not UTF-8 cannot be made (skip_where_a_name_cannot_be_not_utf_8).
    • It builds its locale whatever the gate's locale is, so it fails on main under a UTF-8 gate too, which is what CI runs.
  • test_execute_leaves_the_file_git_config_names_alone (new, SHOULD-1). execute with GIT_CONFIG naming a file that holds a [remote "origin"] url: adoption verified, and the file is byte for byte as it was. The child gets none of the gate's locale variables, so the row runs alike under a UTF-8 and a Latin-1 gate.
  • test_a_clone_with_no_origin_url_goes_on_to_filter_repo (new, NIT-1). _extract_leg itself under a global clone.defaultRemoteName = upstream: the unset exits 5 (recorded as it is raised), the clone's remote.upstream.url is the source, and the leg is pushed.
  • test_an_unset_that_fails_for_any_other_reason_stops_the_leg (new, NIT-1). A config.lock in the clone makes the unset exit 255: CommandFailed, before git filter-repo and with nothing pushed. It needs no git-filter-repo.
  • The earlier rows' setup is now two helpers, extract_the_code_leg and adopt_each_step. The file is ASCII with no backslash escape; each non-ASCII character is built with chr or bytes.

Counts (5 rows; the same file in each tree):

code UTF-8 gate, pip and -E Latin-1 gate, pip and -E
main (_extract_leg as on dffc4226; unchanged in 5926ccca) 4 failed, 1 passed (the GIT_CONFIG row passes: main leaves the file alone) 4 failed, 1 passed
825923c7 (the previous head) 2 failed, 3 passed (the GIT_CONFIG row and the exit-5 row fail) 2 failed, 3 passed
this head 5 passed 5 passed

The two earlier rows fail on main and pass here. The GIT_CONFIG row fails on 825923c7 and passes here. The exit-5 row fails on 825923c7 and on main (no unset to record) and passes here. The lock row passes on 825923c7, which refuses every exit; it guards the new except.

Mutants

Each mutant was applied in a worktree at this head, the five rows plus the two test_the_extraction_stops_at_a_source_branch_in_its_way rows were run under UTF-8 and under Latin-1, and adopt-project.py was restored with its sha256 checked after each one (RESTORED sha256 ok, tree as before).

mutant UTF-8 Latin-1 killed by
M1: drop the unset 4 failed, 3 passed same the two earlier rows, the exit-5 row and the lock row (no unset to see)
M2: the unset moved after git filter-repo 2 failed, 5 passed same the two earlier rows
M3: git remote remove origin instead 5 failed, 2 passed same the any-locale row, the exit-5 row, the lock row and both split-branch rows
M4: drop --file <path> 1 failed, 6 passed same the GIT_CONFIG row
M5: --local instead of --file <path> (exit 129 under GIT_CONFIG) 1 failed, 6 passed same the GIT_CONFIG row
M6: accept every exit of the unset 1 failed, 6 passed same the lock row
M7: accept none (no try) 1 failed, 6 passed same the exit-5 row
M8: --file <work>/config, a path with no file (exit 5, carried on) 3 failed, 4 passed same the any-locale row, the Latin-1 row and the lock row

Gates

All runs used /usr/bin/python3 -m pytest -p no:cacheprovider with one reused basetemp per run kind and -o tmp_path_retention_policy=failed, at most 2 pytest runs at a time. The environment had a stub gh first on PATH, GH_TOKEN=bogus, an empty GH_CONFIG_DIR, GIT_CONFIG_GLOBAL an empty file and GIT_CONFIG_NOSYSTEM=1, and no GIT_ALLOW_PROTOCOL, GIT_SSH_COMMAND, GIT_CONFIG, LANES_* or PYTHON* variable. filter-repo was pip's launcher (a40bce548d2c) unless a row says otherwise.

The tree gated is a scratch merge of this head and origin/main 5926ccca (built with merge-tree and commit-tree; its diff against main is this PR's two files). One hygiene row caught a path in the first attempt (/home/someone/... in the new test, test_no_committed_file_names_a_host_absolute_path); the row now names https://example.invalid/keep-me.git, and everything below ran on the final head.

Gate A, UTF-8 (LC_ALL=C.UTF-8), one pytest, 23 files: 1518 passed, 3 skipped on the scratch merge.

  • the new file, test_adopt_template_values.py, test_adopt_split_branch.py and test_adopt_e2e.py;
  • the other four files that name _extract_leg or _push_the_leg: test_adopt_filter_repo_failure.py, test_adopt_history_gitlinks.py, test_adopt_late_failure.py and test_adopt_plan_escapes.py;
  • test_adopt_check_throwaway_repos.py, test_adopt_partial_clone_source.py, test_adopt_pins.py, test_adopt_git_rm_bytes.py and test_adopt_plan_partial_clone.py (new on main);
  • test_repo_hygiene.py, test_path_guard_hygiene.py, test_cli_reference.py and test_scaffold_leg_path_collisions.py;
  • the files that scan every test file: test_no_auto_maintenance.py, test_non_utf8_git_failures.py, test_git_output_decoding.py, test_setup_project_repo_misdrawn.py, test_shape_advisory.py and test_openreposhape_package.py.
  • Main 5926ccca, the same 22 files without the new one: 1513 passed, 3 skipped. The head's extra 5 are the five rows.
  • Skips (-rs): the same 3 on both, none for lack of git-filter-repo: test_adopt_check_throwaway_repos.py:482 (a disk that keeps case) and test_no_auto_maintenance.py:222 x2 (GIT_CONFIG_GLOBAL set).

tests/test_shape_doctor.py, UTF-8, 4 shards from a bash script (449 ids): Head (scratch merge): 118, 110, 118 and 100 passed, with 3 skipped in the last shard (the PowerShell line, Windows only): 446 passed, 3 skipped. RV1251 and W1247 measured 446 passed and 3 skipped on main at 11560eb9 and b1f45fa7; it was not re-run on 5926ccca, because this PR touches nothing the doctor reads.

Latin-1 (the locale built as above, PYTHONUTF8=0), the new file and test_adopt_template_values.py:

run main 5926ccca this head (scratch merge)
new file + test_adopt_template_values.py, pip launcher 4 failed, 69 passed, 5 skipped (template values only) 4 failed, 74 passed, 5 skipped
the same, -E launcher 5 failed, 68 passed, 5 skipped (template values only) 4 failed, 74 passed, 5 skipped

Merge-trees

git merge-tree --write-tree of this head against:

Overlap with #1214

#1214's WIP guard, in lane 4's unpushed work on fix/1214-latin1-locale-tests, skips test_a_utf8_source_directory_still_adopts_with_local_remotes under Latin-1 by its UTF-8 premise.

Not done, and limits

  • Windows, another one-byte locale (cp1252 included) and a real pipx install were not run. The -E launcher here is a one-line copy of pip's.
  • Read from the code, not run: filter-repo prints nothing else that holds the url. Its other prints of origin are under --sensitive-data-removal, which execute never passes.

🤖 Generated with Claude Code
Lane: openreposhape-4 (openRepoShape-4)

Summary by Sourcery

Make project adoption robust to source paths that cannot be represented by the locale used by git-filter-repo.

Bug Fixes:

  • Prevent adoption from failing under non-UTF-8 locales when a source path contains bytes that git-filter-repo cannot encode in its output.
  • Preserve branch rewriting and existing behavior when extracting adoption legs, including sources with additional branches.

Enhancements:

  • Safely remove only the cloned origin URL before filtering, while isolating the change from externally configured Git config files and tolerating an absent origin URL.
  • Add coverage for locale-sensitive source paths, config isolation, branch preservation, and error handling for unexpected Git config failures.

Tests:

  • Add regression tests covering origin URL handling and Latin-1 adoption scenarios.

…` before `git filter-repo`, so under a Latin-1 locale a source under a directory named with the byte 0xE9 is extracted, where filter-repo died printing that url as U+FFFD, and every branch of the source is still rewritten as before (#1247)

`_extract_leg` clones the source, and the clone's `remote.origin.url` is the source's path, byte for byte. `git filter-repo` prints that url as it removes `origin` (`NOTICE: Removing 'origin' remote ... (was <url>)`), decoded as UTF-8 with `errors='replace'`. Under a Latin-1 locale a directory `caf` plus U+00E9 is the byte 0xE9, the decode makes it U+FFFD, and a Latin-1 stdout cannot hold it: `execute` made both bare leg repositories and stopped at `REFUSED extracting the spec leg`, exit 2, with filter-repo's `UnicodeEncodeError` from `_migrate_origin_to_heads`.

- `_extract_leg` now runs `git config --unset remote.origin.url` in the clone right after its `checkout -B`. filter-repo returns before its NOTICE when the clone has no url, and leaves the remote alone. It still makes each of the clone's `refs/remotes/origin/*` a branch before it asks for the url, so it rewrites every branch of the source as on main.
- Not `git remote remove origin` (#1247's candidate 1): that takes the remote-tracking branches with it, and a leg whose tracking branch holds a `cherry-pick -x` of a commit only another branch reaches then keeps that commit's old id in its message, where main rewrites it. Measured: a different spec-leg tip, the same tree.
- Not `LC_ALL=C.UTF-8` for the child (#1247's candidate 2): it depends on the host's locales, and on Windows `LC_ALL` does not set a pipe's encoding (read, not run). No `PYTHON*` variable reaches a launcher run with `python -E`.
- `tests/test_adopt_filter_repo_origin_url.py`, two rows: `_extract_leg` itself under any locale (no url and every remote-tracking branch when filter-repo starts, no url in its output, the second branch made a branch, the leg pushed), and `plan`, `check` and `execute` for #1247's source in a Latin-1 locale the test builds, with no `PYTHON*` variable but `PYTHONUTF8=0`.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@sourcery-ai

sourcery-ai Bot commented Nov 8, 2026 •

Copy link
Copy Markdown

Reviewer's Guide

Implementation

Unset only the cloned leg’s remote.origin.url before git filter-repo, preserving its remote-tracking branches while avoiding locale-sensitive URL output; scope the unset to the clone’s config and continue only when the key is absent.

  • adopt-project.py L1288-1291, L14812-14848

Tests

Add regression coverage for the Latin-1 failure, retained branch rewriting, config-file isolation, missing-origin handling, and refusal of other unset failures.

  • tests/test_adopt_filter_repo_origin_url.py L1-389

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@brettheap

Copy link
Copy Markdown
Contributor Author

RV1251: independent review of #1251 at 825923c7: NOT READY

(lane openRepoShape-4, independent reviewer RV1251, 2026-11-08T15:34:15Z) One SHOULD and two NITs. The fix works: the defect reproduces on main, the head cures it with both launchers, and the legs come out byte-identical to main's. But the new git config --unset names no file, so the GIT_CONFIG environment variable sends it to a file outside the work directory. Measured: it deletes that file's remote.origin.url, and execute fails where main verifies. The fix is one argument, measured below.

What was measured

Host: git 2.43.0, Python 3.12.3. git-filter-repo 2.47.0 (a40bce548d2c) from lane 4's frvenv (pip's launcher, no -E), and the writer's -E copy of it, used read-only. Latin-1 was built in my own scratch folder: this host has no /usr/share/i18n, so localedef -c -i en_US -f ISO-8859-1 fails ("character map file ISO-8859-1' not found"). I wrote my own charmap and an LC_CTYPEsource, ranlocaledef -c, and set LOCPATH; a child reports iso8859-1for its file system, preferred and stdout encodings. Main was tested atb1f45fa(the PR's base) and at11560eb (origin/mainwhen the review began). The scratch mergee7c11535is11560ebplus825923c`.

1. The defect reproduces on main, with no PYTHON* variable set. My own probe (plan, check, execute --local-remote-dir for a source under caf plus the byte 0xE9, Latin-1, env | grep ^PYTHON empty):

code pip launcher -E launcher
main b1f45fa7 plan 0, check 0, execute 2 plan 0, check 0, execute 2
main 11560eb9 plan 0, check 0, execute 2 plan 0, check 0, execute 2
head 825923c7 execute 0, adoption verified execute 0, adoption verified
merge e7c11535 execute 0, adoption verified execute 0, adoption verified

On main the run ends REFUSED extracting the spec leg with UnicodeEncodeError: 'latin-1' codec can't encode character ... (U+FFFD), raised at print(m) in _migrate_origin_to_heads (git_filter_repo.py line 4462). Both bare legs are left behind.

The existing row test_adopt_template_values.py::test_a_utf8_source_directory_still_adopts_with_local_remotes, under Latin-1:

  • On main, at both b1f45fa7 and 11560eb9: it passes with pip's launcher (1 passed) and fails with the -E copy (1 failed, the same UnicodeEncodeError).
  • On the head it passes with both launchers.
  • With PYTHONIOENCODING=bogus-codec, pip's launcher dies at start-up and the -E copy prints a40bce548d2c.

The writer's claim holds.

2. filter-repo 2.47.0's order (read in frvenv's git_filter_repo.py, sha256 67447413...):

  • _migrate_origin_to_heads (line 4389) first turns every refs/remotes/origin/* into refs/heads/* with one git update-ref --no-deref --stdin. That deletes each remote-tracking ref, origin/HEAD included.
  • Only then does it check if b'remote.origin.url' not in self._config_settings: return (line 4418).
  • The early return skips three things: the --sensitive-data-removal fetch (execute never passes that flag), the NOTICE that prints the url, and git remote rm origin.
  • It skips no ref deletion. By then the migration has deleted every refs/remotes/origin/* on both main and the head. On main, git remote rm origin deleted only config: the [remote "origin"] section, plus branch.main.remote and branch.main.merge.
  • Measured: the leg clones' refs are identical on main and on the head (8, 10, 10 and 14 refs over the four sources below). Only their config differs.
  • What execute pushes does not change. _push_the_leg pushes HEAD:refs/heads/<tracking> to the leg's url.
  • remote.origin.url is used in two other places: the abort message of sanity_check, which --force skips, and the SDR block.

3. The legs are byte-identical to main's (my own probe, rvprobe.py, not probe_legs.py). The sources were built with fixed identities and dates. For each leg's bare repository the probe dumps for-each-ref, cat-file --batch-all-objects --batch-check (every object, reachable or not), rev-list --all --objects, and cat-file -p of every commit, tree and tag. Each row compares the sha256 of that dump:

source main b1f45fa7 = head main 11560eb9 = merge candidate A (git remote remove origin)
standard (3 commits) identical identical identical
second branch release (2 commits) identical identical identical
release + git cherry-pick -x of R onto main identical identical spec leg differs
release + an annotated and a lightweight tag identical identical (not run)
  • The cherry-pick source. On main and on the head the spec leg's tip is 0339cafc, and its message reads (cherry picked from commit d04f2fa8...), which is R as rewritten. Under candidate A the tip is 35b157a7, with the same tree e8315cc4, and the message keeps 71f6473f..., R's id in the source. The rejection of candidate A holds.
  • The mounted submodules (config with the path normalised, and refs) hash the same on main and on the head (649930ba...).

4. git config --unset edge cases.

  • GIT_CONFIG (the constant) is "config" (adopt-project.py:1271), so the command is git config --unset remote.origin.url. It names no file.
  • When the key is absent, git exits 5. run() raises CommandFailed, which is in LATE_FAILURES, so execute prints REFUSED extracting the <role> leg and exits 2, with both legs made.
  • How _extract_leg can reach the unset with no url. A re-run cannot: _extract_leg always clones afresh, and git clone refuses a directory that is not empty. Every form of source becomes a local path that git clone records as remote.<name>.url. Two settings can still leave no remote.origin.url behind, and I measured both:
    • A global clone.defaultRemoteName = upstream. Main ends REFUSED mounting the legs with git remote set-url origin (error: No such remote 'origin'), exit 2, both legs pushed. The head ends earlier, REFUSED extracting the spec leg, with git config --unset remote.origin.url exit 5 and an empty --- output ---, before any push. See NIT-1.
    • The GIT_CONFIG environment variable. See SHOULD-1.
  • The url-less [remote "origin"] is not read again. _push_the_leg pushes to an explicit url, and git submodule add clones the work clone by its path. The mounts' config and refs match main's (above). Afterwards the work clone is read only by rev-parse, rev-list, tree_digest and _tree_of. shape-doctor.py reads no work clone.

5. The rows.

  • Both new rows against main's adopt-project.py (copied into a worktree at the head, from b1f45fa7 and from 11560eb9): 2 failed in each of 4 runs per base (UTF-8 and Latin-1, each with the pip and the -E launcher).
  • On the head: 2 passed in all four combinations.
  • The any-locale row runs (PASSED, not skipped) under LC_ALL=C.UTF-8, under LANG=C.UTF-8 with no LC_ALL (as CI runs), and under LC_ALL=C.
  • The Latin-1 row fails on main under a UTF-8 gate, as claimed.
  • It skips by name where no locale can be built:
    • with a stub localedef that exits 4: localedef could not build en_US.ISO-8859-1 here (exit 4: '[error] rv1251 stub localedef: cannot build here'); a child in it reports ['ascii', 'ascii'];
    • with no localedef on PATH: "no localedef here to build en_US.ISO-8859-1 with".
  • Hygiene: the new file is ASCII, holds no backslash, and is clean under pyflakes and flake8.

6. Mutants (in my own worktree at the head). The rows are both new rows plus the two test_the_extraction_stops_at_a_source_branch_in_its_way rows. After each mutant the file was restored with git checkout and its sha256 checked (a5a3c67b...: OK, tree clean):

mutant UTF-8 Latin-1 killed by
M1 drop the unset 2 failed, 2 passed 2 failed, 2 passed both new rows
M2 the unset moved after git filter-repo 2 failed, 2 passed 2 failed, 2 passed both new rows
M3 git remote remove origin instead 3 failed, 1 passed 3 failed, 1 passed the any-locale row and both split-branch rows
M4 the unset for the code leg only 1 failed, 3 passed 1 failed, 3 passed the Latin-1 row
M5 the unset, then each refs/remotes/origin/* deleted 3 failed, 1 passed 3 failed, 1 passed the any-locale row and both split-branch rows

7. Gate, UTF-8, pip's launcher, with the rules' environment.

origin/main moved twice during the review, so the gate ran on two scratch merges. Neither move touched adopt-project.py.

  • e7c11535 = main 11560eb9 + the head.
  • b073dbcc = main 53bd3171 + the head.
  • After the gate, main moved again to dffc4226, a docstring-only change to scripts/shape_materialize.py. merge-tree with it is clean, and the merged tree differs from main only in the PR's two files.

Gate A, one pytest over 19 files:

  • the new file and test_adopt_template_values.py;
  • the five that name _extract_leg or _push_the_leg: test_adopt_late_failure.py, test_adopt_history_gitlinks.py, test_adopt_filter_repo_failure.py, test_adopt_split_branch.py and test_adopt_plan_escapes.py;
  • test_adopt_e2e.py and test_adopt_partial_clone_source.py;
  • both hygiene files and test_cli_reference.py;
  • test_scaffold_leg_path_collisions.py;
  • test_adopt_git_rm_bytes.py, which the new file imports from, in the same pytest;
  • test_adopt_check_throwaway_repos.py;
  • the files that scan every test or script file: test_no_auto_maintenance.py, test_non_utf8_git_failures.py, test_git_output_decoding.py and test_shape_advisory.py.

tests/test_shape_doctor.py: 449 ids, in 4 shards (118/110/118/103) from a bash script.

tree gate A test_shape_doctor.py
main 11560eb9 (18 files, no new one) 1111 passed, 3 skipped 446 passed, 3 skipped
merge e7c11535 1113 passed, 3 skipped 446 passed, 3 skipped
merge b073dbcc 1113 passed, 3 skipped 446 passed, 3 skipped
  • The two extra passes are the new rows.
  • The skips are the same 6 everywhere, and none is for git-filter-repo (-rs): test_adopt_check_throwaway_repos.py:482 (a disk that ignores case), test_no_auto_maintenance.py:222 x2 (GIT_CONFIG_GLOBAL set), and test_shape_doctor.py:10516 x3 (Windows only).

Latin-1 (new file + test_adopt_template_values.py):

run main 11560eb9 merge e7c11535
pip launcher 4 failed, 69 passed, 5 skipped 4 failed, 71 passed, 5 skipped
-E launcher 5 failed, 68 passed, 5 skipped 4 failed, 71 passed, 5 skipped

8. Merge-trees.

Findings

SHOULD-1: the unset names no file, so GIT_CONFIG in the environment redirects it outside the work directory. git config with no --file, --local or --global takes the file that GIT_CONFIG names (git-config(1)). So run(["git", GIT_CONFIG, "--unset", "remote.origin.url"], cwd=work) unsets the key in that file, not in the clone's own config. Measured with my probe (standard source, UTF-8, GIT_CONFIG naming a file that holds [remote "origin"] url = /home/someone/keep-me.git):

  • Main 11560eb9: plan 0, check 0, execute 0, adoption verified. The file is unchanged.
  • Head 825923c7: execute 2, REFUSED extracting the code leg, git config --unset remote.origin.url, exit 5, with an empty --- output ---. The spec leg is pushed. The file has lost its url line: the spec leg's unset removed it there, and the clone kept its own url. The code leg's unset then found no key.
  • With GIT_CONFIG naming an empty file, both fail execute. Main's filter-repo dies in get_config_settings (ValueError); the head stops at exit 5.

GIT_CONFIG is a legacy variable, and main already writes through it on one narrow path. That path is _resolved's throwaway git config remote.origin.url <base>, for kept relative submodule urls (read, not run). But this PR is the first to write through it on every execute. It also contradicts the comment's and the body's "depends on no locale and no variable".

  • Fix: name the clone's own file, run(["git", GIT_CONFIG, "--file", str(work / ".git" / "config"), "--unset", "remote.origin.url"], cwd=work). work is a fresh, non-bare git clone made with no --separate-git-dir.
    • Measured as a variant: the GIT_CONFIG case gives adoption verified and leaves the file unchanged. The standard and cherry-pick legs are byte-identical to the head's. The Latin-1 0xE9 probe verifies. The four rows used for the mutants give 4 passed under UTF-8 and 4 passed under Latin-1.
    • --local is not the fix: with GIT_CONFIG set, git 2.43 exits 129, error: only one config file at a time.
  • Add a row: _extract_leg (or execute) with GIT_CONFIG naming a file that holds remote.origin.url. The leg is extracted, and the file's bytes are unchanged. On the head it fails, as above.

NIT-1: under clone.defaultRemoteName, the failure moves earlier and says nothing. With a global clone.defaultRemoteName = upstream, main already fails execute at the mount (both legs pushed). The head fails at the unset (exit 5, empty output, nothing pushed). The outcome is not worse, but the new refusal names no cause. Follow-up issue: _extract_leg could clone with --origin origin, and the mount's git remote set-url origin, which fails on main, needs its own answer.

NIT-2: the body says the only difference left is a url-less [remote "origin"]. The work clones also keep branch.main.remote=origin and branch.main.merge=refs/heads/main, which main's git remote rm unset. Nothing reads them: the mounts match main's. The body also calls #1141 a conflict, and it is now clean at 0b8fb320. Body only; no code change is needed.

Not run: Windows, another one-byte locale, a real pipx install, a filter-repo other than 2.47.0, and GIT_CONFIG on a git other than 2.43.

Lane: openreposhape-4 (openRepoShape-4)

…mes the clone's own config file, so a `GIT_CONFIG` in the environment cannot send it to a file of the person's, and a clone with no such url (a global `clone.defaultRemoteName`) goes on, to fail where main fails (#1247)

RV1251 reviewed #1251 at 825923c: one SHOULD and two NITs.

- `_extract_leg` ran `git config --unset remote.origin.url` with no file. With `GIT_CONFIG` in the environment, git writes the file that variable names, so `execute` took the url out of a file of the person's, outside the clone, and ended REFUSED (exit 2) with both legs made; main ends `adoption verified` and leaves that file alone. The call now has `--file <work>/.git/config`. `--local` is no way round it: with `GIT_CONFIG` set, git 2.43 exits 129 (only one config file at a time). `.git` is a directory wherever `execute` reaches the clone: one `git clone` makes it, `work` is an absolute path (`_work_root`), and a `GIT_WORK_TREE` in the environment, which would make the clone another shape, stops `execute` at the legs' `git init --bare` first (measured on main).
- With a global `clone.defaultRemoteName`, the clone's remote is not `origin`, there is no url, and git exits 5: the previous commit refused there, before any leg was pushed and with an empty output block, where main goes on and fails at `mounting the legs` (`No such remote 'origin'`, both legs pushed). `_extract_leg` now goes on from exit 5 and from no other exit; any other is refused as any failed command is. That setting is its own defect (main fails on it too) and is not mended here.
- tests/test_adopt_filter_repo_origin_url.py, three new rows: `execute` with `GIT_CONFIG` naming a file that holds a `[remote "origin"]` url ends `adoption verified` and leaves the file byte for byte; `_extract_leg` itself goes on from exit 5 under a global `clone.defaultRemoteName` and pushes the leg; and an unset that fails for another reason (a `config.lock` in the clone, exit 255) is refused before `git filter-repo` runs. The shared setup of the earlier rows is now two helpers.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
@brettheap

Copy link
Copy Markdown
Contributor Author

F1251: fix round on #1251 for RV1251's NOT READY. New head abeac66d (one new commit on top of 825923c7, no rebase, no amend, pushed without force). The PR body is corrected to match.

Please do a DELTA review of abeac66d only: git diff 825923c7 abeac66d is two files: adopt-project.py (+22 -1) and tests/test_adopt_filter_repo_origin_url.py (+155 -28). 825923c7 is unchanged beneath it.

SHOULD-1 (the unset named no config file): fixed.

  • The call is now run(["git", GIT_CONFIG, "--file", str(work / ".git" / "config"), "--unset", "remote.origin.url"], cwd=work). --local is no way round it: with GIT_CONFIG set, git 2.43 exits 129.
  • Reproduced with GIT_CONFIG naming a file that holds [remote "origin"] url = ...: main adoption verified and the file unchanged; 825923c7 exit 2 (REFUSED extracting the spec leg, both bare legs made, nothing pushed, the file emptied); this head adoption verified and the file byte for byte as it was.
  • work / ".git" is a directory wherever execute reaches the clone: one git clone makes it, work is an absolute path (_work_root), an exported GIT_DIR does not move a clone, and an exported GIT_WORK_TREE (which would) stops execute first at the legs' git init --bare, on main and on this head alike. A path with no directory gives exit 255, which is refused.

NIT-1 (a clone with no origin url): measured, and handled.

  • A global clone.defaultRemoteName = upstream does make the unset exit 5. Main then fails at mounting the legs (No such remote 'origin', both legs pushed); 825923c7 failed earlier, at the unset, with nothing pushed.
  • _extract_leg now goes on from exit 5 and from no other exit (GIT_CONFIG_KEY_ABSENT = 5), so execute fails where main fails, no earlier and no worse. Every other exit is refused as before.
  • clone.defaultRemoteName itself is NOT mended here. It is a follow-up for its own issue (main fails on it too).

NIT-2: the PR body is corrected. The claim "depends on no locale and no variable" now says the fix names its config file, so GIT_CONFIG cannot redirect it. It lists what stays in the work clones (the url-less [remote "origin"], branch.main.remote, branch.main.merge). The stale "#1141 conflicts" note is dropped: it merges clean at 0b8fb320.

Rows (tests/test_adopt_filter_repo_origin_url.py, now 5; the earlier rows' setup is two helpers):

  • new test_execute_leaves_the_file_git_config_names_alone: execute ends adoption verified with GIT_CONFIG naming a file that holds an origin url, and that file is byte for byte as it was.
  • new test_a_clone_with_no_origin_url_goes_on_to_filter_repo: _extract_leg itself under a global clone.defaultRemoteName; the unset exits 5, is gone on from, and the leg is pushed.
  • new test_an_unset_that_fails_for_any_other_reason_stops_the_leg: a config.lock makes the unset exit 255; CommandFailed, nothing pushed. It needs no git-filter-repo.
  • Counts, the same under UTF-8 and Latin-1 and with pip's launcher and the -E copy: main 4 failed, 1 passed; 825923c7 2 failed, 3 passed (the GIT_CONFIG row and the exit-5 row fail); this head 5 passed. The two earlier rows still fail on main and pass here.

Mutants (each restored, sha256 checked; the five rows plus the two split-branch rows, UTF-8 and Latin-1 alike):

  • M1 drop the unset: 4 failed, 3 passed. M2 unset after filter-repo: 2 failed, 5 passed. M3 git remote remove origin: 5 failed, 2 passed.
  • M4 drop --file: 1 failed (the GIT_CONFIG row). M5 --local: 1 failed (the same row).
  • M6 accept every exit: 1 failed (the lock row). M7 accept none: 1 failed (the exit-5 row).
  • M8 a wrong file (<work>/config, exit 5, carried on): 3 failed (the any-locale row, the Latin-1 row, the lock row).

Gates, on a scratch merge of this head and origin/main 5926ccca (diff against main: the PR's two files):

  • 23 files in one pytest under UTF-8: 1518 passed, 3 skipped. Main's 22 files without the new one: 1513 passed, 3 skipped. The same 3 skips on both (a case-keeping disk, and GIT_CONFIG_GLOBAL set x2); none for lack of git-filter-repo (-rs). The list: the new file, template values, split branch, e2e, the other four files that name _extract_leg or _push_the_leg, check throwaway repos, partial clone source, pins, git rm bytes, plan partial clone, both hygiene files, cli reference, leg path collisions, and the six files that scan every test file.
  • test_shape_doctor.py, 4 shards: 446 passed, 3 skipped.
  • Latin-1, the new file plus template values: 4 failed, 74 passed, 5 skipped with either launcher; main (template values only) 4 failed, 69 passed with pip's and 5 failed, 68 passed with -E. The 4 are the same rows on both and are tests: 50 tests in 12 files fail under a Latin-1 locale before and after #1209 (ten of them rows of test_stdout_encoding.py), and whether each is a test that cannot judge under a one-byte locale or a tool defect is not measured (W1196's leftovers; follows #1196) #1214's.
  • One hygiene row (test_no_committed_file_names_a_host_absolute_path) failed on my first attempt, on a /home/... path in the new test; the final commit uses https://example.invalid/keep-me.git, and all of the above ran on it.

Merge-trees of abeac66d: clean against main 5926ccca, #1177 (5208e874), #1225 (73c9f57e) and #1141 (0b8fb320); each merged adopt-project.py keeps the --file call.

Left, outside this PR: a global clone.defaultRemoteName still makes execute fail at mounting the legs (main and this head alike); it wants its own issue.

Lane: openreposhape-4 (openRepoShape-4)

@brettheap

Copy link
Copy Markdown
Contributor Author

RD1251: independent delta review of #1251 at abeac66d: READY

(lane openRepoShape-4, independent delta reviewer RD1251, 2026-11-08) No MUST and no SHOULD. RV1251's SHOULD-1 is cured and pinned by a row, the exit-5 carry-on is narrow, the two earlier rows are as strong as before, and the gate is green on a scratch merge with the current origin/main. Four NITs, none blocking. Scope: git diff 825923c7 abeac66d only (adopt-project.py +22 -1, tests/test_adopt_filter_repo_origin_url.py +155 -28).

What was measured

Host: git 2.43.0, Python 3.12.3, git-filter-repo 2.47.0 (frvenv, pip's launcher) and the -E copy, read-only. Latin-1: the w1247 locale via LOCPATH (a child reports iso8859-1 for its file system, preferred and stdout encodings). Trees: head abeac66d; old 825923c7; main 12122952 (origin/main when I began); scratch merge e9d46e0d = 12122952 + abeac66d (merge-tree --write-tree + commit-tree; its diff against main is the PR's two files). origin/main moved twice while I worked, to 9ec0dc79 and then 9729315f (current at posting), so I gated again on a second scratch merge fab44a0d = 9ec0dc79 + abeac66d and merge-tree'd the head with 9729315f; neither move touches _extract_leg. Environment per the lane rules (stub gh, GH_TOKEN=bogus, empty GIT_CONFIG_GLOBAL, GIT_CONFIG_NOSYSTEM=1, no GIT_SSH_COMMAND).

1. SHOULD-1 is fixed. My own probe (plan, check, execute --local-remote-dir; fixed identities and dates; GIT_CONFIG naming a file that holds [remote "origin"] url = https://example.invalid/keep-me.git, set for execute only):

tree execute verdict the named file
old 825923c7 exit 2 REFUSED extracting the spec leg (filter-repo exit 1, ValueError on the emptied file) CHANGED (now 0 bytes)
main 12122952 exit 0 adoption verified unchanged
head abeac66d exit 0 adoption verified byte-identical (cmp)
merge e9d46e0d exit 0 adoption verified byte-identical (cmp)

The old head fails a little differently from RV1251's run (the spec leg, not the code leg: my file held only the url, so the first unset left it at 0 bytes), the same root. The legs from head and merge hash the same as main's: legs-sha256 322331d052aafd27 for all three. The same equality holds for a release-branch source, a cherry-pick -x source and a tag source (UTF-8, main against head: 0e6aec0a..., 523db0bb..., 5cd20b0c..., each identical), and for a source under caf plus the byte 0xE9 in Latin-1 (old, head and merge verify under both launchers with the same hash; main ends UnicodeEncodeError on U+FFFD, as #1247 says).

2. The exit-5 carry-on is narrow.

  • Exit codes of git config --file <f> --unset remote.origin.url, git 2.43, measured by condition: key present 0; key absent 5; TWO values 5 (with warning: remote.origin.url has multiple values); an existing .git with no config file 5 (silent); config.lock present 255; .git is a file 255 (Not a directory); directory missing 255; syntax error or unreadable file 3; --local with GIT_CONFIG set 129 (only one config file at a time). So only 5 goes on, and a lock, a bad file or a usage is refused. The row for the lock (255) and the mutants below pin that.
  • The comment above the call tells the truth on each point I could test: the 129 under --local, .git a directory made by the clone, work absolute (_work_root: os.path.realpath or mkdtemp; the only caller passes work_root / name), the 255 for a lock, and execute failing where main fails under clone.defaultRemoteName. Probe: a global clone.defaultRemoteName = upstream: main and head both end REFUSED mounting the legs, git remote set-url origin ... exit 2, error: No such remote 'origin', both legs pushed, the same leg hashes. One overstatement, NIT-1 below.
  • Two remote.origin.url values: going on is right. I put the clone's own url last and a first value before it (a stand-in: no git clone of a source leaves two, and a template config with a url did not add a second one to a clone, measured), then ran _extract_leg on main and on the head:
    • UTF-8, source under 0xE9: both extracted.
    • Latin-1, source under 0xE9: both end CommandFailed ... UnicodeEncodeError: 'latin-1' codec can't encode character U+FFFD, filter-repo having met a url, as main does. The unset exited 5 and removed nothing.
    • So going on is exactly main's behaviour and no worse; refusing exit 5 would turn a UTF-8 run that passes on main into a refusal. (--unset-all would also cure the Latin-1 case. Optional, NIT-2.)
  • Other environment variables, main against head, identical outcomes: GIT_DIR naming an empty directory (stops at git rev-parse --is-inside-git-dir), GIT_DIR naming the source's .git (stops at git checkout -B in the clone: reference is not a tree, before the unset), GIT_WORK_TREE naming the out directory (stops at source-not-top-level), and GIT_WORK_TREE with GIT_DIR naming the source's .git (stops at git init --bare), GIT_CONFIG naming an empty file or a file that is not there (filter-repo itself dies, ValueError or unable to read config file), and a work directory named with the byte 0xE9 (verifies, UTF-8 and Latin-1, hash 322331d052aafd27).

3. The refactor keeps the two earlier rows as strong as before. I diffed 825923c7:tests/... against the head by eye and by run. The assertions of both rows are unchanged line for line. Row 1 (test_filter_repo_starts_with_no_origin_url_and_every_branch) keeps its spy on adopter.run and every assertion after the call; its setup moved into extract_the_code_leg, which makes head, the bare leg and work = tmp_path / "work" (WORK == "work") and calls _extract_leg with the same literals. The helper's two git(...) calls now run after the monkeypatch.setattr, but they are conftest.git, not adopter.run, so started is unchanged. Row 2 (the Latin-1 execute row) calls adopt_each_step and assert_adopted: the same four runs with the same arguments, and the same assertions in the same order. Runs:

  • The old two rows' bodies (the file at 825923c7) against the head's adopt-project.py: 2 passed in all four combos (UTF-8 and Latin-1, pip and -E).
  • The new helpers against 825923c7's adopt-project.py: 2 failed (GIT_CONFIG row, exit-5 row), 3 passed, in all four combos; the two earlier rows pass there, as they did before.
  • Strength on mutants, the old file and the new one side by side (both files in one pytest in the mutant worktree, so the same adopt-project.py meets both): M1 (drop the unset) fails both earlier rows of each file; M2 (unset after filter-repo) fails both earlier rows of each file; M3 (git remote remove origin) fails the any-locale row of each file and passes the Latin-1 row of each. The pattern is the same in the old bodies and the refactored ones, in UTF-8 and in Latin-1 (table in point 5).

4. The rows (new file, 5 rows, the same result in UTF-8 and Latin-1 and with pip's and the -E launcher; the Latin-1 row ran, not skipped):

tree UTF-8 pip, E Latin-1 pip, E
main 12122952 4 failed, 1 passed 4 failed, 1 passed
old 825923c7 2 failed, 3 passed 2 failed, 3 passed
head abeac66d 5 passed 5 passed
merge e9d46e0d 5 passed 5 passed

On main the failures are the two earlier rows, the exit-5 row and the lock row; the GIT_CONFIG row passes (main leaves the file alone). On 825923c7 the GIT_CONFIG row and the exit-5 row fail; the lock row passes by design (it refuses every exit). The lock row needs no git-filter-repo: with it off PATH, 1 passed on head and on old, 1 failed on main, UTF-8 and Latin-1; the whole file with it off PATH is 1 passed, 4 skipped, each skip by name ("git filter-repo is not installed").

5. Mutants in my own worktree at the head (sha256 2528d02bcac3 restored and checked after each). Rows: the five plus test_adopt_split_branch.py::test_the_extraction_stops_at_a_source_branch_in_its_way (2 ids), 7 in all; UTF-8 and Latin-1 gave the same result for every mutant. BASE (no mutant): 7 passed in each.

mutant result killed by
M1 drop the unset (F1251) 4 failed, 3 passed (new file + split rows); old-file rows 1 and 2 fail too both earlier rows, the exit-5 row, the lock row
M2 unset after git filter-repo (F1251) 2 failed, 5 passed; old-file rows 1 and 2 fail too both earlier rows
M3 git remote remove origin (F1251) 5 failed, 2 passed (new file + split rows); old-file row 1 fails, its row 2 passes the any-locale row, the exit-5 row, the lock row, both split-branch rows
M4 drop --file (F1251) 1 failed, 6 passed the GIT_CONFIG row
M5 --local (F1251) 1 failed, 6 passed the GIT_CONFIG row
M6 accept every exit (F1251) 1 failed, 6 passed the lock row
M7 accept none (F1251) 1 failed, 6 passed the exit-5 row
M8 --file <work>/config (F1251) 3 failed, 4 passed the any-locale row, the Latin-1 row, the lock row
MA accept 255 as well 1 failed, 6 passed the lock row
MC unset for the code leg only 1 failed, 6 passed the Latin-1 row
MG unset remote.origin.pushurl instead 2 failed, 5 passed the any-locale row and the Latin-1 row
MB accept exit 3 as well 7 passed SURVIVES (see NIT-3)
MJ carry on from 5 for the code leg only 7 passed SURVIVES (see NIT-3)
ME --unset-all (an improvement, not a defect) 2 failed, 5 passed the exit-5 row and the lock row (see NIT-2)

M1 to M8 match F1251's table exactly (M1 to M3 re-run with the old file's two rows alongside, as point 3 says).

6. Gate on the scratch merges e9d46e0d (main 12122952) and fab44a0d (main 9ec0dc79), UTF-8, pip's launcher, at most 2 pytest runs at a time; both gave the same counts:

  • Gate A, one pytest, 23 files: 1518 passed, 3 skipped on e9d46e0d (923 s) and 1518 passed, 3 skipped on fab44a0d (832 s). The files: the new file, test_adopt_split_branch.py, test_adopt_template_values.py, test_adopt_e2e.py; the files that name _extract_leg or _push_the_leg (test_adopt_filter_repo_failure.py, test_adopt_history_gitlinks.py, test_adopt_late_failure.py, test_adopt_plan_escapes.py); test_adopt_check_throwaway_repos.py, test_adopt_plan_partial_clone.py, test_adopt_partial_clone_source.py, test_adopt_pins.py, test_adopt_git_rm_bytes.py; test_repo_hygiene.py, test_path_guard_hygiene.py, test_cli_reference.py, test_scaffold_leg_path_collisions.py; test_no_auto_maintenance.py, test_non_utf8_git_failures.py, test_git_output_decoding.py, test_setup_project_repo_misdrawn.py, test_shape_advisory.py, test_openreposhape_package.py. This matches F1251's 1518 on 5926ccca.
  • -rs, both runs: 3 skips, none for lack of git-filter-repo: test_adopt_check_throwaway_repos.py:482 (a disk that keeps case) and test_no_auto_maintenance.py:222 x2 (GIT_CONFIG_GLOBAL set). grep -c "filter-repo is not installed" over the log: 0.
  • tests/test_shape_doctor.py, 449 ids in 4 shards from a bash script (118/110/118/103): 118, 110, 118 and 100 passed with 3 skipped in the last shard (the PowerShell line, Windows only): 446 passed, 3 skipped, on e9d46e0d; the same shard counts and the same 446 passed, 3 skipped on fab44a0d.
  • Latin-1 (the new file + test_adopt_template_values.py; main runs the template-values file only, so its counts exclude the 5 rows): main pip 4 failed, 69 passed, 5 skipped; scratch merge pip 4 failed, 74 passed, 5 skipped; main -E 5 failed, 68 passed, 5 skipped; merge -E 4 failed, 74 passed, 5 skipped. The 4 are the same rows on both sides (test_plan_refuses_a_flag_no_file_can_hold x2, test_execute_refuses_a_local_source_directory_that_is_not_utf8, test_plan_and_check_say_the_same_sentence), tests: 50 tests in 12 files fail under a Latin-1 locale before and after #1209 (ten of them rows of test_stdout_encoding.py), and whether each is a test that cannot judge under a one-byte locale or a tool defect is not measured (W1196's leftovers; follows #1196) #1214's. The fifth on main under -E is test_a_utf8_source_directory_still_adopts_with_local_remotes, which the merge passes. All as F1251's table.
  • Static: the new file is ASCII, holds no backslash, is clean under pyflakes and flake8; no line is over 79 columns.
  • CI at my last look: SonarCloud Code Analysis, package and tests-git-bash pass; tests was still pending.

7. Merge-trees (git merge-tree --write-tree), all clean:

Findings

NIT-1 (a comment that overstates). GIT_CONFIG_KEY_ABSENT's doc reads "What git config --unset exits with when the key is not there (git 2.43). Every other failure of it is a different number ... which _extract_leg does not go on from." Exit 5 is also what git exits with for two values and for an existing .git with no config file (measured above), and _extract_leg does go on from both. The call's comment is accurate. Fix: say "5: the key is not there, is there twice, or the file is not there (git 2.43); the unset removes nothing in each, and filter-repo then runs as on main". Going on is right in all three (point 2).

NIT-2 (optional hardening). --unset-all instead of --unset would also remove a second url (the stand-in case above: the Latin-1 UnicodeEncodeError would not appear). No clone execute makes holds two values, so this is hypothetical; if taken, the exit-5 row and the lock row, which find the unset by the literal list element "--unset" in args, need ("--unset", "--unset-all") (mutant ME shows both fail on the new spelling).

NIT-3 (two survivors, both low value). MB (exit 3 gone on from) and MJ (exit 5 gone on from for the code leg only) survive: the lock row stands for "any other exit" (255) and the exit-5 row calls the code role only. If wanted, one execute row under a global clone.defaultRemoteName asserting REFUSED mounting the legs with both legs pushed would pin the claim the module docstring and the comment make ("fails where main fails") and kill MJ; I measured that outcome on main and on the head by probe, not in a row. Not needed to land.

NIT-4 (a detail of the PR body). The body's counts and merge-trees cite main 5926ccca; main is 9729315f now and the numbers are unchanged on 12122952 and 9ec0dc79 (Gate A 1518 passed, 3 skipped; merge clean on all three). Nothing to change unless the body is edited again.

Not run: Windows, another one-byte locale, a real pipx install, a git other than 2.43, a filter-repo other than 2.47.0.

Lane: openreposhape-4 (openRepoShape-4)

@brettheap brettheap added this to the v1.2.1 milestone Nov 8, 2026
brettheap pushed a commit that referenced this pull request Nov 8, 2026
…does_not_spell_it_as_utf_8` are held under emulated UTF-8, Latin-1 and ASCII codecs, `validate-family.py` is held to call `escape_unencodable_stdout()` first, and the two rows that can judge under Latin-1 run there (#1214)

RV1258's review of #1258 (S1, S2, N1, N3):

- tests/test_adopt_template_values.py (S1): the premise guard on
  `test_a_utf8_source_directory_still_adopts_with_local_remotes` is gone,
  with the `A_NAME_HELD_AS_UTF_8` import it left unused there. The row
  passes under Latin-1 with the pip-installed git-filter-repo; with a
  launcher started as `python -E` it fails on #1247's traceback until #1251
  lands, which is the row's own failure and not a premise it cannot judge.
  #1258 no longer carries a guard for #1251 to drop.
- tests/test_non_utf8_name_helpers.py (S2): 20 rows hold
  `skip_where_the_locale_does_not_spell_it_as_utf_8` under `os.fsencode`,
  `os.fsdecode` and `sys.getfilesystemencoding` emulated as UTF-8, Latin-1
  and ASCII have them: 15 for the question that skips each of five texts in
  each locale (none, "cannot spell", "writes", "reads") and for the reason's
  encoding, ending and ASCII, and 5 that hold the emulation to this run's
  real locale. A helper that built UTF-8's bytes with `surrogatepass`, or
  dropped, reordered or inverted a question, now fails them under CI's
  UTF-8 locale.
- tests/test_bootstrap_spelling.py (N1): the first-statement row also reads
  the holder's `validate-family.py`, so a call moved after `parse_args`
  fails it.
- tests/test_family_head_by_hand_bytes.py (N3):
  `test_surrogateescape_reads_the_issues_branch_as_caf_and_u_dce9` asks
  `os.fsdecode(b"\xe9")` in its `if`, in place of the helper, so under
  Latin-1 it passes where it skipped; under UTF-8 and ASCII it asserts as
  before.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
@brettheap
brettheap marked this pull request as ready for review November 8, 2026 21:16
@sourcery-ai

sourcery-ai Bot commented Nov 8, 2026

Copy link
Copy Markdown

Sorry @brettheap, you've used your own review budget of 250,000 diff characters for the last 7 days.

You can request another review in 6 days by commenting @sourcery-ai review. Upgrade to get a review now.

@sonarqubecloud

sonarqubecloud Bot commented Nov 8, 2026

Copy link
Copy Markdown

@brettheap
brettheap merged commit 8e6f532 into main Nov 8, 2026
5 checks passed
@brettheap
brettheap deleted the fix/1247-filter-repo-origin-url branch November 8, 2026 21:18
brettheap added a commit that referenced this pull request Nov 9, 2026
…encode, so it passes under Latin-1 where it ended in a traceback, and 45 rows in 11 test files that cannot judge under a one-byte locale skip there on their own premise (#1214) (#1258)

## Goal

#1214 counts 50 tests in 12 files that fail under a Latin-1 locale before and after #1209, and asks of each whether it is a test that cannot judge under a one-byte locale, or a tool that misbehaves there. All 50 are settled here:

- **3 are a tool defect, fixed:** a family holder's `scripts/validate-family.py` ended in a `UnicodeEncodeError` traceback, exit 1, on any stdout that cannot hold U+2026, when the holder passed.
- **45 cannot judge under Latin-1,** and now skip there on their own premise, which the skip reason states. 18 fail in the test process itself, before the tool runs. In the other 27 the tool answers rightly for the bytes Latin-1 gives, and the row expects UTF-8's.
- **2 judge under Latin-1 as they are written, and carry no guard:** `test_a_utf8_source_directory_still_adopts_with_local_remotes` (it passes with the pip-installed git-filter-repo, and fails with a `python -E` one on #1247's tool defect; see "Left") and `test_surrogateescape_reads_the_issues_branch_as_caf_and_u_dce9` (its `if` asks the one thing its assertion needs). Both came out of RV1258's review of the first commit.

Under Latin-1 with the pip-installed git-filter-repo, none of the 50 fails on this head. Under UTF-8 every row keeps its outcome, and the rows added pass.

The classification is W1214's: lane 4's first writer of #1214, who read each test's code and stopped at a checkpoint with half the guards written and nothing run. This branch finishes the guards, runs every gate below, and measures each row. RV1258 reviewed the first commit; the second answers it (next section).

## The second commit

RV1258 reviewed the first commit, `c8641c691` (NOT READY: two SHOULDs, three NITs, no MUST; #1258 (comment)). The second commit, `cd9f3cfd1`, answers it on top of the first, with no rebase. It changes four test files and no tool:

- **S1, a premise guard on a row that passes:** the guard on `test_a_utf8_source_directory_still_adopts_with_local_remotes` is gone, and so is the `A_NAME_HELD_AS_UTF_8` import it alone used in `tests/test_adopt_template_values.py`.
  - The guard skipped a row that passes: on main under Latin-1, with CI's pip-installed git-filter-repo, the row passes. Its skip reason (the tool "names it as" a name that is not UTF-8) was false for it, because `execute` adopts the source.
  - The row now runs under Latin-1 and passes with the pip launcher. With a launcher started as `python -E` it fails on #1247's tool defect (git-filter-repo's `UnicodeEncodeError` on U+FFFD) until #1251 lands. That is a failure of the tool, and #1214's rule sends such a row to an issue of its own, not to a skip.
  - **#1258 and #1251 are now independent of each other.** This PR carries no guard for #1251 to drop, so the earlier plan, that whichever of the two lands second drops this PR's guard, is void. Neither waits for the other.
- **S2, nothing CI runs held the helper's answers:** `tests/test_non_utf8_name_helpers.py` gets 20 rows, written as that file writes its Windows rows: `os.fsencode`, `os.fsdecode` and `sys.getfilesystemencoding` are replaced for one test by UTF-8, Latin-1 and ASCII as POSIX has them.
  - 15 rows (five texts, three locales) hold which question skips the text (none, "cannot spell", "writes" or "reads"), and that the reason names the encoding, ends with the row's premise, and is ASCII.
  - 5 rows hold the emulation to this run's real locale: the helper answers the same with the real `os` as with the emulation of its file system encoding.
  - RV1258's mutant A5 (UTF-8 bytes built with `surrogatepass` instead of `surrogateescape`) now fails 3 rows under CI's UTF-8 locale; before, it made 11 rows skip silently. The mutants that survived, A1, A2 and A4, now fail 5, 1 and 6 rows (see the mutants below).
- **N1:** the first-statement row of `tests/test_bootstrap_spelling.py` also reads `templates/family-root/scripts/validate-family.py`, so RV1258's mutant D3 (the `escape_unencodable_stdout()` call moved after `parse_args`) fails it.
- **N3:** `test_surrogateescape_reads_the_issues_branch_as_caf_and_u_dce9` no longer asks the helper. Its `if` also asks `os.fsdecode(b"\xe9") == chr(0xDCE9)`, so under Latin-1 the row runs its first assertion and passes where it skipped, and under UTF-8 and ASCII it asserts as before.
- **N2, known and left:** under emulated Windows codecs the helper skips the U+DCE9 rows that carry no Windows mark, with a premise that is false on Windows. That is reasoned and emulated, not run on Windows, and CI runs Linux only (#597).

## The 50, by file

Kinds:
- **a1:** the test process itself cannot make or pass the name under Latin-1, so it raises `UnicodeEncodeError` before the tool runs. Guard: the existing `skip_where_the_environment_cannot_carry`.
- **a2:** the tool runs and answers rightly for the bytes Latin-1 gives, and the row expects UTF-8's reading or spelling. Guard: the new `skip_where_the_locale_does_not_spell_it_as_utf_8(text, premise)`, asked only of the text the row's premise is about.
- **b:** a tool defect.
- **c:** the row judges under Latin-1 as it is written, and runs there with no guard.

`test_stdout_encoding.py` comes first, as #1214 asks. 18 a1 + 27 a2 + 3 b + 2 c = 50.

| File | Rows | Kind | Why it fails under Latin-1 | Guard |
|---|---|---|---|---|
| `tests/test_stdout_encoding.py` | 10: `test_plan_reports_every_name_whatever_its_stdout_can_encode` (3), `test_plan_on_the_posix_default_stdout`, `test_every_tool_exits_alike_whatever_its_stdout_can_encode` (6) | a1 | The test makes a file or directory named U+65E5 U+672C, or passes that name on a command line, and Latin-1 cannot encode it. | `skip_where_the_environment_cannot_carry`, in `plan_arguments` and in each of the six builders. (`bump-leg-dry-run` writes the name as bytes and passes, so it has none.) |
| `tests/test_adopt_pins.py` | 5 `[zwj]` rows | a1 | U+200D cannot go on the command line, or through `copytree`. | `skip_where_the_environment_cannot_carry(name)` |
| `tests/test_adopt_pins.py` | 4 `[not-utf-8...]` rows | a2 | The byte 0xFF is read as U+00FF, printable text the tool takes, so `plan` goes on where UTF-8 gives U+DCFF and a refusal. | `A_BYTE_READ_AS_A_SURROGATE`, where the name holds U+DCFF |
| `tests/test_adopt_pins.py` | 5 rows that compare a `pin` or `write` line | a2 | A Latin-1 stdout has no U+2026, so the tool prints the digest's ellipsis as `\u2026`, as #214 designed. | `PRINTED_AS_ITSELF`, just before the line is compared |
| `tests/test_pin_source_unreadable.py` | 3 `[not-ascii-*]` | a1 | The path U+65E5 U+672C `-missing` cannot go on the command line. | `skip_where_the_environment_cannot_carry` |
| `tests/test_pin_source_unreadable.py` | 3 `[not-utf-8-*]` | a2 | `miss<0xFF>ing` reaches the tool as text, and is printed as itself, not as `\udcff`. | `A_BYTE_READ_AS_A_SURROGATE` |
| `tests/test_family_tracking_branch.py` | `test_each_act_refuses_the_tracking_branch_then_lands_on_a_branch` `[add]`, `[bump]`, `[remove]` | **b** | Each act passes until `validate(holder)`. The holder's `validate-family.py` prints `members/X: tree digest recomputes (<12 hex>...)`, ending in U+2026, and never escaped its stdout, so it ended in a traceback, exit 1. | none: the tool is changed |
| `tests/test_family_tracking_branch.py` | `test_a_branch_ending_in_a_no_break_space_is_pushed_as_itself` | a2 | `git switch -c feat<U+00A0>` writes the single byte 0xA0, so the branch is not UTF-8, and the tool rightly refuses it (#765). | `A_NAME_HELD_AS_UTF_8` |
| `tests/test_adopt_template_values.py` | the `--elected-by` and `--reference` rows of `test_plan_refuses_a_flag_no_file_can_hold` whose value holds U+DCE9, and `test_plan_and_check_say_the_same_sentence` | a2 | 0xE9 is read as U+00E9, text `plan` takes. | `A_BYTE_READ_AS_A_SURROGATE` (in the flag test, only where the value holds U+DCE9) |
| `tests/test_adopt_template_values.py` | `test_a_utf8_source_directory_still_adopts_with_local_remotes` | **c** | With the pip launcher it does not fail under Latin-1 on this head or on main: its `caf<U+00E9>` directory is the single byte 0xE9, and `execute` adopts the source all the same. It fails only where git-filter-repo is started as `python -E`, on #1247's tool defect (see "Left"), which is an issue of its own and not a premise to skip on. | none (a guard was here in the first commit, and RV1258's S1 took it out) |
| `tests/test_clone_url_bytes.py` | the 4 `[bidi-override-*]` rows | a2 | The directory is made from U+202E's UTF-8 bytes E2 80 AE. Latin-1 reads them as three characters, one of them the C1 control U+0080, so the tool rightly says "a control character". | `A_NAME_READ_AS_UTF_8`, in `skip_where_this_system_cannot_name` |
| `tests/test_bump_leg_branch_and_push_line.py` | 2 | a2 | The branches `feat<U+00A0>` and `main<U+00A0>` hold the single byte 0xA0. | `A_NAME_HELD_AS_UTF_8` |
| `tests/test_bootstrap_leg_moves.py` | 2 | a2 | `bootstrap.py` prints U+2014 escaped on a Latin-1 stdout. | `PRINTED_AS_ITSELF`, just before the assert |
| `tests/test_update_shape_apply_lines_and_headers.py` | 1 | a2 | The branch `feat<U+00A0>`. | `A_NAME_HELD_AS_UTF_8` |
| `tests/test_adopt_spelled_names.py` | 1 | a2 | The test writes `caf<U+00E9>.md` as 0xE9, so git holds a name that is not UTF-8, and the C-locale child prints `caf\udce9.md`, not `caf\xe9.md`. | `A_NAME_HELD_AS_UTF_8`, after its C-locale probe |
| `tests/test_family_member_branch_not_utf8.py` | `[trailing-no-break-space]` | a2 | `_member_head` reads the byte 0xA0 as U+DCA0, which is the branch git wrote. | `A_NAME_HELD_AS_UTF_8`, only where the branch is not `NOT_UTF_8_BRANCH`: `[not-utf8]` passes under Latin-1 and still runs there |
| `tests/test_family_head_by_hand_bytes.py` | 1 | **c** | Its `if`, `os.fsencode(chr(0xDCE9)) == b"\xe9"`, holds under Latin-1 too, and its assertion, `os.fsdecode(LATIN_1) == branch`, holds only where the locale reads 0xE9 as U+DCE9 (UTF-8, ASCII). Its first assertion holds in every locale. | none (RV1258's N3): the `if` also asks `os.fsdecode(b"\xe9") == chr(0xDCE9)`, so under Latin-1 the row runs its first assertion and passes |

## What changed, file by file

18 files: one tool, `tests/conftest.py`, and 16 test files.

- **`templates/family-root/scripts/validate-family.py`** (the tool):
  - `main`'s first statement is now `escape_unencodable_stdout()`, imported from `repo_shape`, as in `siblings.py` and both roots' `bootstrap.py` (#391, #454).
  - That call adds no version-skew risk. The function shipped in the same commit as `spelled` (ec4a7a0), which the file already imports, and it is not in `test_pinned_copy_text.py`'s `NEWER_THAN_A_KEPT_LIBRARY`.
  - The holder's shape-pin digests are written by `init`, so there is no static digest to move.
- **`tests/test_family.py`:** one new row, `test_the_gate_passes_on_a_stdout_that_cannot_hold_its_notes`. It runs the holder's gate with `PYTHONIOENCODING=latin-1` and expects exit 0, no traceback, and the two notes ending in `\u2026)`.
- **`tests/conftest.py`:**
  - The new helper, `skip_where_the_locale_does_not_spell_it_as_utf_8(text, premise)`, asks three questions, each through `os` at call time: whether `os.fsencode` can spell the text, whether it gives UTF-8's bytes, and whether `os.fsdecode` reads those bytes back as the text.
  - Four premise sentences go with it: `A_BYTE_READ_AS_A_SURROGATE`, `A_NAME_HELD_AS_UTF_8`, `PRINTED_AS_ITSELF` and `A_NAME_READ_AS_UTF_8`. Every skip reason is ASCII.
  - It is never asked inside `skip_where_a_name_cannot_be_not_utf_8`. A branch whose bytes are not UTF-8 is one in every locale, so those rows still judge under Latin-1, and this takes none of #1224's N1 over-skip.
- **The 11 files with guards** are the files of the table above that name a guard. Each guard sits just before the first line that needs its premise. `tests/test_family_head_by_hand_bytes.py` has none: its `if` is narrowed (N3).
- **`tests/test_non_utf8_name_helpers.py`** (the second commit): 20 rows hold `skip_where_the_locale_does_not_spell_it_as_utf_8` under emulated UTF-8, Latin-1 and ASCII (S2, above).
- **`tests/test_bootstrap_spelling.py`** (the second commit): the first-statement row takes `validate-family.py` as a third file (N1).
- **`tests/test_non_utf8_name_callers.py`:** `windows_names_it` now emulates Windows' `os.fsdecode` too (UTF-8 with `surrogatepass`, `windows_fsdecode`).
  - Without it, the bidi guard in `skip_where_this_system_cannot_name` asked this run's real Latin-1 `os.fsdecode` under an emulated Windows.
  - Measured: `test_where_windows_holds_a_bidi_override_the_name_check_does_not_skip` then failed under Latin-1 (1 failed, 35 passed), where it passes on main. With the emulation, the file gives 36 passed in both locales.
  - Real Windows reads UTF-8 in every locale, which is what that row's own reasoning ("NTFS holds U+202E, so the `bidi-override` row ... runs on Windows as it does here") assumes.

## Runs

**Environment.** One runner for every run: `/usr/bin/python3 -m pytest -p no:cacheprovider` (Python 3.12.3).
- A stub `gh` first on PATH, a bogus `GH_TOKEN` and an empty `GH_CONFIG_DIR`.
- `GIT_CONFIG_GLOBAL` an empty file, `GIT_CONFIG_NOSYSTEM=1`, the test identity, and `EMAIL` set.
- `GIT_ALLOW_PROTOCOL`, `GIT_SSH_COMMAND` and the `LANES_*` variables unset.
- **Every run counted here had git-filter-repo 2.47.0 on PATH** (`git filter-repo --version`: `a40bce548d2c`, CI's pin, pip-installed in a venv). An earlier pair of head runs without it skipped 58 adoption rows, and is not counted.
- That git-filter-repo's launcher is the pip one, with no `python -E`, so a test's own `PYTHONIOENCODING` reaches it. The `-E` comparison is the last paragraph of this section.

**Locales.**
- UTF-8: `LC_ALL=C.UTF-8`.
- Latin-1: built with `localedef -c`, as #1153's `test_adopt_one_byte_locale.py` builds one; then `LOCPATH`, `LC_ALL=en_US.ISO-8859-1`, `PYTHONUTF8=0`. Python reports `iso8859-1` and reads 0xFF as U+00FF.
- ASCII: `LC_ALL=C PYTHONUTF8=0 PYTHONCOERCECLOCALE=0`.

**Round one's gate** (the first commit, `c8641c691`, on main `bd3e9c148`, 27 files, F1214's runs): UTF-8 1520 passed and 1 skipped on main, 1521 and 1 on the head; Latin-1 123 failed, 1373 passed, 25 skipped on main, and 44 failed, 1404 passed, 74 skipped on the head. RV1258 re-ran it on 35 files (main `5926ccca`, merge `103ada82`) and got the same transitions. The gate below replaces it.

**The gate: 29 files, on a scratch merge.** The merge is this head (`cd9f3cfd1`) into `origin/main` `46fe6ac19` (local, never pushed, clean); the baseline is `46fe6ac19` itself. Both with the pip launcher.
- The 27 files of round one: the 23 files on main that use `skip_where_a_name_cannot_be_not_utf_8` or `on_a_branch_that_is_not_utf_8`, with `test_repo_hygiene.py` (W1196's 24, less the two files #1209 adds, plus `test_family_leg_path_by_hand_bytes.py`), and four more that run the changed code: `test_family.py`, `test_pinned_copy_text.py`, `test_update_shape_kept_helper.py` and `test_local_remote_dir_urls.py`. They include `test_non_utf8_name_helpers.py`.
- Two more for the second commit: `test_path_guard_hygiene.py` (the second hygiene file) and `test_bootstrap_spelling.py`.

| Run | main `46fe6ac19` | scratch merge with this head |
|---|---|---|
| 29 files, UTF-8 | 1873 passed, 1 skipped | 1895 passed, 1 skipped |
| 29 files, Latin-1 | 128 failed, 1721 passed, 25 skipped | 49 failed, 1775 passed, 72 skipped |
| the 50, UTF-8 | 50 passed | 50 passed |
| the 50, Latin-1 | 49 failed, 1 passed | **0 failed**, 5 passed, 45 skipped |
| the 50, Latin-1, `-E` launcher | 50 failed (on `bd3e9c148`, round one) | 1 failed, 4 passed, 45 skipped |

The 5 that pass under Latin-1 are the 3 tracking-branch rows (the tool fix), `test_a_utf8_source_directory_still_adopts_with_local_remotes` and `test_surrogateescape_reads_the_issues_branch_as_caf_and_u_dce9`.

Main moved twice while this was gated, none of its commits touching a file of the gate or of this PR. The merge was run again on each: on `9729315f1` the same 29 files, with identical outcomes by test id in both locales (1895 passed, 1 skipped; 49 failed, 1775 passed, 72 skipped); on `801a7d6d0` the 50 and the four files the second commit changes (`test_non_utf8_name_helpers.py`, `test_bootstrap_spelling.py`, `test_family_head_by_hand_bytes.py`, `test_adopt_template_values.py`). The 50 give the same as above in all three modes (UTF-8 50 passed; Latin-1 pip 0 failed, 5 passed, 45 skipped; Latin-1 `-E` 1 failed, 4 passed, 45 skipped), the four files give 385 passed under UTF-8, and 6 failed, 371 passed, 8 skipped under Latin-1: the 5 `test_bootstrap_spelling.py` rows and `test_execute_refuses_a_local_source_directory_that_is_not_utf8`, all of which fail on main too.

**By test id, from main to the scratch merge:**
- **UTF-8:** 22 new rows, all passed: the 20 of `test_non_utf8_name_helpers.py`, the `[validate-family]` row of the first-statement test, and the first commit's `test_the_gate_passes_on_a_stdout_that_cannot_hold_its_notes`. Nothing else changes: no new skip, no row from passed to failed. The one skip is `test_stdout_encoding.py`'s Windows default-stdout row, on both.
- **Latin-1:**
  - 0 rows from passed to failed.
  - 0 from passed to skipped. (The first commit had one, the S1 row; it passes now.)
  - 32 from failed to passed: the 3 tracking-branch rows and `test_surrogateescape_reads_the_issues_branch_as_caf_and_u_dce9` of the 50, and 28 other rows of `test_family.py` whose holder's gate ended in the same traceback.
  - 47 from failed to skipped: 45 of the 50, and the 2 bidi rows of `test_local_remote_dir_urls.py`, which share `BAD_DIRECTORIES`.
  - 22 new rows, passed.
  - Each of the 49 failures fails on main too: the rows #1209 settles, the rows under "Left", and 5 rows of `test_bootstrap_spelling.py` (see "Left").

**On a scratch merge with #1209** (main `46fe6ac19`, #1209 at `13a2c58cb`, then this head; local, never pushed, both merges clean). #1209 shares four files with this PR: `tests/conftest.py`, `tests/test_non_utf8_name_callers.py`, `tests/test_non_utf8_name_helpers.py` and `tests/test_stdout_encoding.py`. Run on 8 files: the three test files among those four, #1209's `test_adopt_plan_paths_spelled.py` and `test_run_script_encoding.py`, and `test_adopt_template_values.py`, `test_family_head_by_hand_bytes.py` and `test_bootstrap_spelling.py`. Against main plus #1209 alone:
- UTF-8: 483 passed and 1 skipped, then 504 passed and 1 skipped: the 21 new rows (the 20, and the `[validate-family]` row), nothing else.
- Latin-1: 19 failed, 411 passed, 54 skipped, then 5 failed, 433 passed, 67 skipped: 21 new rows passed, 1 failed to passed, 13 failed to skipped. The 5 failures are the `test_bootstrap_spelling.py` rows, which fail on both. Of the 50, the 15 in these files give 13 skipped and 2 passed, none failed.

**The other 59 test files that name `validate-family`** (round one, on the first commit, UTF-8): 3374 passed, 28 skipped, 0 failed. The second commit changes no tool.

**The same launcher started as `python -E`** (W1247's copy of it with `-E` added, used read-only), Latin-1, the 50: on main `bd3e9c148`, **50 failed**, the 50 exactly as #1214 lists them. On the first commit, 0 failed. On this head, **1 failed**, 4 passed, 45 skipped: the S1 row, `test_a_utf8_source_directory_still_adopts_with_local_remotes`, on #1247's traceback (`UnicodeEncodeError` on U+FFFD in `git_filter_repo.py`'s `_migrate_origin_to_heads`, then `REFUSED extracting the spec leg`). It stays red with that launcher until #1251 lands, and the other 49 rows are as with the pip launcher.

## The new rows, and mutants

Each mutant was made in a scratch worktree at the head and restored afterwards, with each file's sha256 checked. "UTF-8" and "Latin-1" name the locale of the run.

**The second commit's rows.** The helper's own rows run in CI's UTF-8 locale, with the three locales emulated.

| Mutant | Run | Result |
|---|---|---|
| none (the head), `test_non_utf8_name_helpers.py` | UTF-8 | 39 passed (19 before, 20 new) |
| the new rows against main's `tests/conftest.py`, which has no helper | UTF-8 | the file does not import: `cannot import name 'skip_where_the_locale_does_not_spell_it_as_utf_8'` |
| A5: the helper's UTF-8 bytes built with `surrogatepass` | UTF-8 | **3 failed**: the `byte-e9` row in each of the three locales. Before, the same mutant made 11 rows skip silently under UTF-8 and failed none (RV1258). |
| A1: the first question's skip taken as UTF-8's bytes | UTF-8 | **5 failed**: `iso8859-1` and `ascii` for `bidi-override` and `ellipsis`, and `ascii-e-acute` |
| A2: the second question dropped | UTF-8 | **1 failed**: `iso8859-1-e-acute` (it reads the bytes back and says "reads", not "writes") |
| A4: only the third question | UTF-8 | **6 failed**: the rows A1 and A2 fail, together |
| A3: the third question dropped | UTF-8 | **1 failed**: `iso8859-1-byte-e9` |
| A6: the third question inverted | UTF-8 | **9 failed** |
| the encoding in the reason named `utf-8` always | UTF-8 | **7 failed** |
| the row's premise left out of the first question's reason | UTF-8 | **5 failed** |
| the UTF-8 bytes built with `strict` | UTF-8 | **4 failed**: the three `byte-e9` rows, and the row that holds the emulation to the real locale |
| the second and third questions swapped | UTF-8 | **1 failed** |
| the first question catching any exception | UTF-8 | survives, and is equivalent: `os.fsencode` of a str raises only `UnicodeEncodeError` |
| D3: `validate-family.py`'s `escape_unencodable_stdout()` moved after `parse_args` | UTF-8 | **1 failed**: the `[validate-family]` row |
| main's `validate-family.py` under the head's tests | UTF-8 | **2 failed**: the `[validate-family]` row and `test_the_gate_passes_on_a_stdout_that_cannot_hold_its_notes` |
| N3's narrowed `if` taken out (main's `if`, with no helper call) | Latin-1 | **1 failed**: `test_surrogateescape_reads_the_issues_branch_as_caf_and_u_dce9` (it passes under UTF-8) |

On the 50 under Latin-1 the helper's mutants are as in round one, re-measured on this head: A3 gives **10 failed** (it was 11; the N3 row no longer asks the helper), the first question unguarded gives **11 failed**, and A1, A2 and A4 survive (5 passed, 45 skipped), because on Linux the third question alone decides there, as RV1258 found. Only the new rows tell them apart.

**The first commit's rows** (mutants made on `c8641c691`, which the second commit does not change):

| Mutant | Run | Result |
|---|---|---|
| none (the head), the new row of `test_family.py` | UTF-8 | 1 passed |
| main's `validate-family.py` under the head's tests (the new row on main) | UTF-8 | **1 failed**: the new row |
| `validate-family.py`'s `main` without the `escape_unencodable_stdout()` call (import kept) | Latin-1 | **4 failed**: the new row, and the `[add]`, `[bump]`, `[remove]` rows of `test_each_act_refuses_the_tracking_branch_then_lands_on_a_branch` |
| the bidi guard taken out of `skip_where_this_system_cannot_name` | Latin-1 | **6 failed**: the 4 bidi rows of `test_clone_url_bytes.py` and the 2 of `test_local_remote_dir_urls.py`, the same `BAD_DIRECTORIES` |
| `windows_names_it` without the `os.fsdecode` emulation | Latin-1 | **1 failed**: `test_where_windows_holds_a_bidi_override_the_name_check_does_not_skip` |
| the guard of `test_the_member_head_is_the_branch_git_wrote` asked of every branch (its `branch != NOT_UTF_8_BRANCH` dropped) | Latin-1 | `[not-utf8]` goes from passed (the head) to skipped; no row fails. A skip fails no run, so only a comparison of outcomes sees this one. |

## Merge-trees

`git merge-tree --write-tree` of the head (`cd9f3cfd1`):
- against `origin/main` `46fe6ac19`: clean;
- against #1209 `13a2c58cb`, #1185 `d193617c7`, #1154 `8a7828332`, #1251 `abeac66de` and #1198 `d38e4e36d`: each clean;
- against the other open PRs that touch any of these 18 files, at their heads: #1263 `9ef8f0ab5`, #1246 `0deac3a65`, #1231 `aca00dfd9`, #1227 `2d56c1906`, #1178 `c4beba193`, #1172 `2eabec8e0` and #1125 `9549006fe` are clean. #1201 `eac177af9` conflicts at `docs/handbook.html`, which this branch does not touch, and conflicts there against `origin/main` alone too.

#1209 changes `skip_where_a_name_cannot_be_not_utf_8` and the callers fixture `a_system_that_carries_the_byte`. The new helper sits more than 100 lines from the first, and `windows_names_it` 65 lines from the second. #1209 also edits `tests/test_non_utf8_name_helpers.py`, where the second commit adds its rows at the end of the file; the two merge without a conflict, and the merged file's rows pass (see "Runs").

## Left, and outside this issue

- **W1214's filter-repo defect is filed separately, as #1247**, and #1251 (a draft for it) is independent of this PR.
  - What W1214 found: `adopt-project.py execute` fails for a Latin-1 user whose source path holds U+00E9. The leg clone's `remote.origin.url` holds the byte 0xE9, git-filter-repo decodes it with `errors='replace'` and prints U+FFFD to a Latin-1 stdout, and `execute` stops at `REFUSED extracting the spec leg`.
  - **Which launcher runs git-filter-repo decides it.** One started as `python -E` ignores the `PYTHONIOENCODING` the tool gives its children; a pip-installed one, as CI installs it, is not started that way. Measured here (see "Runs"): `test_a_utf8_source_directory_still_adopts_with_local_remotes` passes on main under Latin-1 with the pip launcher, and fails there with a `-E` copy of the same launcher. W1196's list of 50 has this row failing, which this bench gives only with the `-E` launcher.
  - **Independent of #1251.** This PR no longer guards that row (RV1258's S1), so it carries nothing for #1251 to drop, and the earlier plan, that whichever of the two PRs lands second drops this PR's guard, is void. #1251 changes `_extract_leg` in `adopt-project.py` and adds `tests/test_adopt_filter_repo_origin_url.py`, and touches none of these 18 files (`git merge-tree` against its head `abeac66de` is clean). The row passes under Latin-1 with the pip launcher whichever lands first. With a `-E` launcher it fails on #1247's traceback until #1251 lands, which is the tool's failure showing, not a premise this PR can judge.
- **N2 (RV1258), known and left:** under emulated Windows codecs, the helper skips the U+DCE9 rows that carry no Windows mark, with a premise that is false on Windows. It is reasoned and emulated, not run on Windows; CI runs Linux only (#597).
- **5 rows of `tests/test_bootstrap_spelling.py` fail under Latin-1** on main, on this head and on the merge with #1209 alike. It is a file #1214 does not list, read from the failure messages only: four rows end in a `UnicodeEncodeError` on U+2028, which Latin-1 cannot encode, and `test_a_branch_name_is_spelled_in_every_line_that_names_it` fails its assertion. They are left for an issue of their own.
- **8 rows in two files #1214 does not list fail under Latin-1** on main, on this head and on the merge with #1209 alike:
  - 6 rows of `test_pinned_copy_text.py`: the tool prints U+2014 or U+2026 escaped on a Latin-1 stdout, and the row compares the character.
  - `test_family.py`'s `test_init_writes_the_holders_agent_files`: it reads the UTF-8 file it checks in the locale's encoding.
  - `test_family.py`'s `test_commit_one_refuses_a_trailer_that_is_no_text_before_it_stages`: `DID NOT RAISE Refusal`, a byte Latin-1 reads as text.
  - These are read from their failure messages only, not classified per test. They are left for an issue of their own.
- **The fourth row of `tests/test_adopt_template_values.py` that fails under Latin-1 on main** is `test_execute_refuses_a_local_source_directory_that_is_not_utf8`. It is not one of the 50, and this PR leaves it alone.
  - It asks `skip_where_a_name_cannot_be_not_utf_8`, and #1209 gives that helper the locale question. So it skips at #1209's head, where the 50 were counted, and it skips on the scratch merge with #1209.
  - It fails on main and on this head alike, so it is #1196's (#1209's) row, not #1214's.
  - The other three rows of that file that fail on main are among the 50: the two U+DCE9 flag rows and `test_plan_and_check_say_the_same_sentence`. Each skips here.
- **#1224 is untouched.** This helper takes none of N1's over-skip; N2 to N5 stay #1224's.

Closes #1214

Lane: openreposhape-4 (openRepoShape-4)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
brettheap pushed a commit that referenced this pull request Nov 9, 2026
brettheap pushed a commit that referenced this pull request Nov 9, 2026
… no known cause remains, as the clone before it is named `origin` whatever `clone.defaultRemoteName` says, where #1251's said `execute` then fails at `mounting the legs` (#1261)

#1251's comment gave the setting as the cause of the exit 5 and said
`execute` fails where main fails. With #1268 in, the clone carries
`REMOTE_NAMED_ORIGIN`, so it has an `origin` url and the unset exits 0
under the setting and under the empty control. Only the comment changes:
the tolerance stays as a guard.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
brettheap pushed a commit that referenced this pull request Nov 9, 2026
…et's exit-5 tolerance makes its clone as main did, without `REMOTE_NAMED_ORIGIN`, since #1268's clone names `origin` under `clone.defaultRemoteName` and the unset no longer exits 5 there (#1261)

Main 8e6f532 (#1251) and this PR each merge cleanly, and their
combination breaks one row: `test_a_clone_with_no_origin_url_goes_on_to_filter_repo`
sets `clone.defaultRemoteName = upstream` and expects the clone's unset to
exit 5, and with #1268 the clone is named `origin` and the unset exits 0
(`assert [] == [5]`). The row now sets `adopter.REMOTE_NAMED_ORIGIN` to
`[]`, which makes the clone main made, so it still pins that exit 5 is gone
on from and no other exit is. With the tolerance dropped from
`_extract_leg` the row fails. The docstrings say that no known cause of the
exit remains.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
brettheap added a commit that referenced this pull request Nov 9, 2026
…: a kept `GNUmakefile/` is a directory GNU make stops at, `python3 scripts/bootstrap.py` names `python` on Windows, and the template says what to run where `make` reads another file (#1207)

**#1132, the parts that hold on main: the assembly-root template says what to run where GNU make reads a kept `GNUmakefile` or `makefile` first; a kept DIRECTORY of either name is named as one GNU make stops at, in the `CONTRACTS_DIR` line and in `execute`'s NEXT; every sentence that names `python3 scripts/bootstrap.py` for a person to run names `python` on Windows too; and two follow-up texts no longer say more than is true (RV1105b's NIT-2 and NIT-3a).**

This PR was built on main `961640c6`. Lane 4's #1121 (#1047) landed as `0ed3e57f8` at 21:37Z, and this round merged it in (`6fa1edd56`): NEXT now words a kept file (#1121's) and a kept directory (this PR's) through one lookup and one clause. #1105 landed as `12122952b` on 2026-11-08, and this PR merges it in (see "Main merge after #1105"). The items that live only in #1105's code, and the parts of #1121's that this merge does not do, are in their own issue, #1240 (see "Left"). Item 5 is #1206.

Lane 4's #1105 (#1048) landed as `12122952b` at 16:45Z. This round merges main into the branch with `git merge origin/main`, never a rebase, and does it twice:
- main `46fe6ac19` as merge `7b0192bde`;
- then NIT-A in its own commit, `e5e077940`;
- then main `9729315f1` as merge `01e93b6d1`, the head. Lane 1's #1123 had landed meanwhile, and one of its rows meets this PR's directory line (see "The second merge, after #1123").

The first merge conflicted in `scripts/shape_materialize.py` only: 3 hunks, all in `collision_follow_up`, as "Landing order" said. `adopt-project.py` and `templates/assembly-root/AGENTS-shape.md` merged with no conflict.

Both sides' behaviour stays: #1105's second `GNU_MAKE_READS`, its `_predict_collisions` lookup and its collision line, and this PR's `_make_reads_first`, `_make_reads_first_clause` and NEXT. None of #1240's unification is done here (one tuple, one lookup).

### The three hunks

| hunk | this PR (`6fa1edd56`) | main (`46fe6ac19`, #1105) | resolution |
|---|---|---|---|
| 1. The docstring's NIT-4 sentence | "This said "both callers say it", and `execute` calls it nowhere" | "`Materialized.follow_ups()` would say this of them, and nothing calls it" | **Main's.** Both sides rewrote the same sentence for the same finding. Main's also names `Materialized.follow_ups()`, which #1240's item G changes. So this PR no longer touches that sentence, and the last `scripts/shape_materialize.py` bullet under "What changed" is #1105's text now. |
| 2. The docstring's Makefile paragraphs | the `BOOTSTRAP_COMMAND` sentence and NIT-2's tail | the heading "WHERE `make` READS THE MERGED FILE", and the "BUT GNU MAKE READS" paragraph | **Both.** Main's heading and both paragraphs. This PR's sentences on `BOOTSTRAP_COMMAND` and on NIT-2's tail go in the first paragraph, and one new sentence goes in the second: "Both name that command as `BOOTSTRAP_COMMAND` does, `python` on Windows as well (#1132)." |
| 3. The returns | two `return`s, each one sentence | `arrive`, `joint`, `meanwhile` and `until` set per branch, then one pair of `return`s | **#1105's structure, with a per-branch `then` in place of `until`.** With no `reads_first`, the line is this PR's, byte for byte. With one, it is #1105's, byte for byte, except that the command a person runs is `BOOTSTRAP_COMMAND`, both in `meanwhile` and in "and then ... runs it". |

- **Hunks 1 and 2 carry no code.** In the merged file they sit at lines 1022-1023 and 1032-1070, inside `collision_follow_up`'s docstring (lines 1014-1084).
- **The rendered lines.** I loaded the function from `6fa1edd56`, from main, and from the merge, and rendered each `reads_first` (none, `GNUmakefile`, `makefile`) with and without `scripts/bootstrap.py` aside.
  - With no `reads_first`, the merge equals `6fa1edd56` (2 of 2).
  - With one, it equals main with " (`python` on Windows)" after `python3 scripts/bootstrap.py` in those two places (4 of 4). For a root that keeps `Makefile` and `GNUmakefile`, the line now ends "...; until then `python3 scripts/bootstrap.py` (`python` on Windows) is what the shape's `make bootstrap` runs".
- **NIT-2's tail where `make` reads another file** stays #1105's own: "neither `make bootstrap` nor `python3 scripts/bootstrap.py` runs the shape's bootstrap until then, and then `python3 scripts/bootstrap.py` (`python` on Windows) runs it". #1105's review fixed that branch for the same finding, so it needs nothing more.
- **Of #1240's list,** this round does item C for #1105's collision line, as #1240 asks a resolution to say. So the "with `python3`" part of "Left"'s second bullet is done. Item B, the kept directory, stays: #1105's lookup asks `_root_keeps`, so a root that keeps `Makefile` and `GNUmakefile/` is told GNU make "reads the source's `GNUmakefile`". Mutant U3 below shows that no row pins this line for a directory.

### #1105's test pins

`tests/test_adopt_collision_make_reads.py` is #1105's file, and it pins the texts this PR changes, as "Landing order" expected.
- **Four pins move.** `MERGE_IS_ENOUGH` and `BOTH_MERGES` (no `reads_first`) move to this PR's words. `MEANWHILE` and `SCRIPT_MERGED` (with one) move to `python` on Windows. All four go through a new `COMMAND`.
- **One comment changes.** The comment on the `Makefile+scripts` row now says what NIT-2's tail says.
- **Measured:** before the move, the six adopt and pin files gave 11 failed and 242 passed, and the 11 are exactly the rows that use those four pins. After the move, 253 passed.
- **On main's code:** main `46fe6ac19`'s four production files (`adopt-project.py`, `scripts/shape_materialize.py`, `templates/assembly-root/AGENTS-shape.md` and `README.md`) were swapped into the mutant worktree at `e5e077940`. 64 of the three files' 106 rows fail:
  - in this file, exactly those 11 rows, and the other 20 pass;
  - in the new file, 34 of 35, as before (NIT-4's row passes);
  - in `tests/test_adopt_next_make_reads_first.py`, 19 of 40, as before.

  The four files were then restored, each matched the head by sha256 (4 of 4), and the tree was clean.

### NIT-A

`tests/test_adopt_next_make_reads_first.py:64` called #480's NOTE "unchanged", but the merge of #1121 moved that pin to `python` on Windows. The comment now says the NOTE "names `python` on Windows too since #1132". The change is a comment only, in its own commit.

### The second merge, after #1123

Lane 1's #1118 and #1123 landed while the first merge was being gated: `9ec0dc79c` at 17:30Z and `9729315f1` at 17:47Z. Both merge with `e5e077940` with no conflict in the text. The predicted merge with `9ec0dc79c` passed (gate P below). The predicted merge with `9729315f1` failed 1 row of 254 (gate P2):
- **The row:** #1123 adds `test_a_name_only_a_disk_that_ignores_case_takes_for_makefile[makefile-directory]` to `tests/test_adopt_make_reads_first.py`. For a kept DIRECTORY `makefile/`, it expects the `CONTRACTS_DIR` line a kept `makefile` FILE gets ("only once `makefile` does"). #1123's own message says that line is not true for a directory, and that the row works as a crash guard for `twins` in `_makefile_follow_up`. This PR changes exactly that line: a kept directory is one GNU make stops at.
- **The fix, in the merge `01e93b6d1`:** the row now expects `SHAPES + written_as("makefile")`, as #1123 wrote it, which is the part that guards `twins`. This PR's directory clause follows, through a new `stops_at` helper beside `reads`. The comment above `ANSWERED` and the row's docstring now say so. Nothing else changes in the merge.
- **Mutants on the row.** Each ran alone in the mutant worktree at `01e93b6d1` against `tests/test_adopt_make_reads_first.py` (34 rows). Each was restored with `git checkout` and matched by sha256 (`adopt-project.py` `3c2cb5f5bea5`), and the tree was clean after each.

| id | mutant | rows failing | result |
|---|---|---|---|
| D1 | `_make_reads_first` drops a directory's `/`, so the line is the one #1123's row pinned | 1 of 34, the row | killed |
| D2 | #1123's R10: `twins` reads the entry with its slash | 1 of 34, the row, with `IndexError` | killed |

### Mutants on the resolution

H3a-H3g and U1-U3b are the first merge's. All ran in the mutant worktree at `e5e077940`.
- **Method:** each mutant was applied alone, then restored with `git checkout`. Each restore matched by sha256 (`shape_materialize.py` `b18f09d7c396`, `adopt-project.py` `2055a81acdc6`), and the tree was clean after each.
- **Rows:** H3a-H3g, U3 and U3b ran against 93 rows: `tests/test_adopt_collision_make_reads.py` (31), the new file (35) and `tests/test_adopt_e2e.py` (27). U1 ran against the new file, `tests/test_adopt_make_reads_first.py` (33) and `tests/test_adopt_collision_make_reads.py`, 99 rows. U2 ran against the new file and `tests/test_adopt_next_make_reads_first.py` (40), 75 rows.
- **Unmutated,** every row passes (gate A below).

| id | mutant | rows failing | result |
|---|---|---|---|
| H3a | hunk 3, no `reads_first`: `meanwhile` back to main's plain `python3` | 4 of 93 | killed |
| H3b | hunk 3, no `reads_first`: the script tail back to main's "before both merges are made" | 4 of 93 | killed |
| H3c | hunk 3, with `reads_first`: `meanwhile` without `BOOTSTRAP_COMMAND` (main's) | 5 of 93 | killed |
| H3d | hunk 3, with `reads_first`: "and then ... runs it" without `BOOTSTRAP_COMMAND` (main's) | 3 of 93 | killed |
| H3e | hunk 3, with `reads_first`: this PR's tail in place of #1105's | 3 of 93 | killed |
| H3f | hunk 3: `reads_first` ignored, so the resolution is this PR's side whole | 15 of 93 | killed |
| H3g | hunk 3, with `reads_first`: #1105's `joint` ("; and") lost | 3 of 93 | killed |
| U1 | `_makefile_follow_up` drops `_make_reads_first` (`first = None`) | 31 of 99 | killed |
| U2 | `_next_steps` drops `_make_reads_first` (`first = None`) | 35 of 75 | killed |
| U3 | `_predict_collisions` asks `_make_reads_first` in place of #1105's lookup | 0 of 93 | **survived** |
| U3b | `_predict_collisions` passes no `reads_first`, so #1105's lookup is lost in the merge | 15 of 93 | killed |

- **H3c and H3d** are killed only by rows that use the moved `MEANWHILE` and `SCRIPT_MERGED`. Those pins are what hold `BOOTSTRAP_COMMAND` in #1105's branch.
- **U3 survives,** and that is #1240's item B. For a kept file, both lookups give the same name. They differ only for a kept directory, where `_make_reads_first` adds the `/`, and no row runs `_predict_collisions` on a root that keeps `Makefile` and `GNUmakefile/`. A row now would pin the line #1240 is to correct, so this round adds none.

### Runs

Each run went through the lane's runner, with git-filter-repo 2.47.0 (CI's pin) on PATH, on a commit with a clean tree.

| run | git | files | passed | failed | skipped |
|---|---|---|---|---|---|
| gate A2 | 2.43.0 | `01e93b6d1`, the head: the 12 files below | 1096 | 0 | 3: the PowerShell rows (`test_shape_doctor.py:10516`), which run only on a Windows host |
| gate B2 | 2.47.1 | `01e93b6d1`: the same 12 files | 1096 | 0 | 3: the same |
| gate A | 2.43.0 | `e5e077940`, after the first merge: the 12 files below | 1095 | 0 | 3: the same |
| gate B | 2.47.1 | `e5e077940`: the same 12 files | 1095 | 0 | 3: the same |
| gate P | 2.43.0 | the predicted merge of `e5e077940` with main `9ec0dc79c` (#1118; tree `ba3f3c1f3`, a local commit object, not pushed): the six adopt and pin files, plus #1118's `tests/test_adopt_root_shape_paths.py` and `tests/test_adopt_symlink_target_bytes.py` | 509 | 0 | 0 |
| gate P2 | 2.43.0 | the predicted merge of `e5e077940` with main `9729315f1` (#1123; tree `0eb290ae2`, a local commit object): the six adopt and pin files | 253 | 1: #1123's `makefile-directory` row, which the second merge moves | 0 |
| gate P4 | 2.43.0 | the predicted merge of `01e93b6d1` with main `801a7d6d0` (#1106; tree `25bc27d39`, a local commit object): the six adopt and pin files, plus #1106's `tests/test_adopt_one_byte_locale.py` and `tests/test_adopt_unenterable_source_and_locale.py` | 277 | 0 | 0 |

The files are the six adopt and pin files (`tests/test_adopt_collision_make_reads.py`, `tests/test_pinned_copy_text.py`, the new file, `tests/test_adopt_next_make_reads_first.py`, `tests/test_adopt_e2e.py` and `tests/test_adopt_make_reads_first.py`, 253 rows), plus `tests/test_shape_doctor.py` and `tests/test_scaffold_leg_path_collisions.py`, which adopt changes need, plus the hygiene five (`test_path_guard_hygiene.py`, `test_repo_hygiene.py`, `test_agents_md_codes.py`, `test_cli_reference.py` and `test_pinned_copy_text.py`). That is 1098 rows in one run at `e5e077940`, and 1099 at `01e93b6d1`, where #1123 adds one row.

All of this was measured on main `961640c68` with GNU make 4.3, offline.

| item | on main |
|---|---|
| 1, the template | `AGENTS-shape.md` (the "Work from here" paragraph and the five-commands table) and `README.md` (Get started, and the parking steps) give `make bootstrap` with no caveat. With the template's own `Makefile` beside a plain `GNUmakefile` or `makefile`, `make -n bootstrap` exits 2, `No rule to make target 'bootstrap'`. |
| 2, a kept directory | With `GNUmakefile/` or `makefile/` beside `Makefile`, `make bootstrap` exits 2 with `make: *** GNUmakefile: Is a directory.  Stop.`, or the same with `makefile`. It does this for every target, and for each directory alone too. Main's `CONTRACTS_DIR` line says "`make` there exports `CONTRACTS_DIR` only once `GNUmakefile` does". NEXT prints `make bootstrap` for a root that keeps only `GNUmakefile/`. Beside a kept `Makefile`, it prints #480's NOTE that the targets "arrive only once the follow-up merges the two". Rendered by the lane's `probe_texts.py` on main. |
| 3, `python3` | The template's `scripts/bootstrap.py` says `python3 scripts/bootstrap.py (python on Windows)`. #480's NOTE and the Makefile collision follow-up's "until then" name `python3` alone. |
| NIT-2 | The no-`reads_first` script-aside tail says "neither `make bootstrap` nor `python3 scripts/bootstrap.py` runs the shape's bootstrap before both merges are made". In a root that keeps its own `Makefile` and `scripts/bootstrap.py`, merging the script alone makes `python3 scripts/bootstrap.py` print the shape's `SHAPE-BOOT`, while `make bootstrap` still exits 2. Measured again by a row below. |
| NIT-3a | `_predict_collisions` says the wording comes from "the same function `execute` reports its actual collisions through", and `collision_follow_up` says "Both callers say it". `execute` never calls `collision_follow_up`: it carries the plan's stored `follow_ups:` into the split message. |

`adopt-project.py`:
- **`_make_reads_first(surviving)`** gives the first of `GNUmakefile` and `makefile` the root keeps. It reads `GNU_MAKE_READS`' order, asks the way `_root_keeps` asks, and adds a `/` for a DIRECTORY. **`_make_reads_first_clause`** words the clause. For a file, the words are main's, byte for byte. For a directory, it says: "GNU make at the root stops at the source's directory `GNUmakefile/`, the first of `GNUmakefile`, `makefile` and `Makefile` it finds (`GNUmakefile: Is a directory.`), so ... only once the root keeps no directory of that name".
- **`_makefile_follow_up`** (the `CONTRACTS_DIR` line) asks both. A kept file's line is unchanged: `tests/test_adopt_make_reads_first.py` passes as it is.
- **`_next_steps`** takes `surviving=`, the plan's root paths, which `cmd_execute` passes as `paths_for["root"]`, as #1121 does.
  - Where a kept DIRECTORY stops make, the command is `python3 scripts/bootstrap.py`. The NOTE says GNU make stops there. Beside a kept `Makefile`, it also says the targets run there once the follow-up merges the two, and only once the directory is gone. Where the script went aside too, alone or with the `Makefile`, the NOTE names that command after the merges.
  - Since the merge of #1121, a kept FILE goes through the same lookup and the same clause. For a file the clause gives #1121's words byte for byte, and its NOTEs end in `BOOTSTRAP_COMMAND` too.
- **`BOOTSTRAP_COMMAND`** is in every NOTE: #480's, #1121's and the directory's. Each command line a person pastes stays `python3 scripts/bootstrap.py`.
- **`_predict_collisions`' docstring** says what the plan stores and what `execute` carries (NIT-3a).

`scripts/shape_materialize.py`:
- **`BOOTSTRAP_COMMAND`** = "`python3 scripts/bootstrap.py` (`python` on Windows)", as the template's script names it.
- **The Makefile collision follow-up** says "until then `python3 scripts/bootstrap.py` (`python` on Windows) is what `make bootstrap` runs".
- **Where the script went aside too,** the follow-up says "so `python3 scripts/bootstrap.py` (`python` on Windows) runs the shape's bootstrap once the script is merged, and `make bootstrap` once both merges are made" (NIT-2).
- **The docstring's "Both callers say it"** paragraph says what is true (NIT-3a's twin, #1105's review NIT-4). #1105 made the same fix, and the merge keeps main's text (see "Main merge after #1105").

`templates/assembly-root/`:
- **`AGENTS-shape.md`:** the "Work from here" paragraph adds "; where the root keeps a `GNUmakefile` or a `makefile`, which GNU make reads before `Makefile`, run `python3 scripts/bootstrap.py` (`python` on Windows), which is what the shape's `make bootstrap` runs." A sentence after the five-commands table says they are the shape's Makefile's targets, which `make` at the root reaches only where the file it reads first holds them, or includes a Makefile that does.
- **`README.md`:** one sentence after Get started covers `make bootstrap` "here and below". A second says `make park` and `make resume` below work there only where that file holds them, or includes a Makefile that does.
- **This is a template byte change, so every project re-pins.** No digest of either file is stored in this repository. `tests/` was grepped for every changed line, and only this PR's own rows pin them (see "Template pins").

Tests:
- **`tests/test_adopt_e2e.py`:** two pins move to the new words, at :312 (the "until then" sentence) and at :447-450 (NIT-2's tail).
- **`tests/test_adopt_next_make_reads_first.py`** (#1121's): the merge moves three pins, `OWN_MAKEFILE_NOTE`, `RUNS` and `script_aside`, to `python` on Windows. #480's NOTE merged with no textual conflict, so without them its rows fail.
- **The new file `tests/test_adopt_make_bootstrap_followups.py`** has 35 rows:
  - the template's sentences, held to its `Makefile` (`PYTHON ?= python3`, `bootstrap:` runs `$(PYTHON) scripts/bootstrap.py`) and to `scripts/bootstrap.py`'s own words;
  - `make -n bootstrap` against the template's `Makefile` beside each kept name, each row asserting the `AGENTS-shape.md` caveat that measurement backs;
  - `_make_reads_first` (10 roots);
  - the `CONTRACTS_DIR` line for 4 directory roots;
  - NEXT for a directory, beside a kept `Makefile` (both names), after both merges, and after the script's merge alone;
  - #480's NOTE, called both as main's signature allows and with `surviving=`;
  - the collision follow-up's two sentences;
  - NIT-2 measured with the template's `Makefile` and stand-in scripts, and tied to the follow-up's new tail;
  - three real adoptions of a source holding `GNUmakefile/rules.mk`. One is kept by a `--path-policy` rule, so `plan` writes the line, `check` prints it and the split message carries it. One is answered `root`. In both, NEXT is asserted, `make -n bootstrap` in the pasted clone exits 2 with `GNUmakefile: Is a directory.`, and the printed command exits 0. In the third, the question is answered `code`: NEXT names `make bootstrap`, and that command runs in the pasted clone.

### This round (#1207's review, issuecomment-6374516382)

| finding | what changed |
|---|---|
| SHOULD-1 | A row pins NEXT where only `scripts/bootstrap.py` went aside beside a kept `GNUmakefile/` (`test_next_after_the_script_merge_names_python3_where_make_stops`). It fails under the review's mutant X1. |
| SHOULD-2 | The "Left" list is one issue, #1240. |
| SHOULD-3 | "Landing order", below. #1121 landed while this round ran, and is merged and resolved here. |
| NIT-1 | `AGENTS-shape.md`'s sentence after the table loses "(above)": nothing above names a Makefile that includes another. |
| NIT-2 | `README.md` names `make park` and `make resume`. |
| NIT-3 | Beside a kept `Makefile`, the directory NOTE names the merge as well as the directory. Its row is parametrized over `GNUmakefile/` and `makefile/`. |
| NIT-4 | An adoption sends `GNUmakefile/` to the code leg, and NEXT names `make bootstrap`. It fails under the review's mutant X6. |
| NIT-5 | The notes for the squash message at landing, below. |

Measured at the merge head `6fa1edd56`, in a scratch worktree:
- main `0ed3e57f8`'s bytes of the four production files (`adopt-project.py`, `scripts/shape_materialize.py`, `templates/assembly-root/AGENTS-shape.md`, `templates/assembly-root/README.md`) were checked out over the head;
- the new file (35 rows) and `tests/test_adopt_next_make_reads_first.py` (40 rows) ran through the lane's runner;
- the four files were restored with `git checkout`, and each matched the head by sha256 (`c94bd19b`, `12555f39`, `8660bafb`, `b3f9409b`).

| file | fail on main | pass on main |
|---|---|---|
| the new file | 34 | 1: `test_an_adoption_sending_a_gnumakefile_directory_to_a_leg` |
| `tests/test_adopt_next_make_reads_first.py` | 19 | 21 |

Main now has #1121, so its `_next_steps` takes `surviving=`. The NEXT rows for a kept directory therefore fail on their words, not on a `TypeError`. Main reads `GNUmakefile/` as a file: "then run `python3 scripts/bootstrap.py`; GNU make at the root reads the source's `GNUmakefile`, ...". This is the case for the SHOULD-1 row, the after-the-merges row, both directory rows, and NIT-3's `makefile/` row.

The new file's other rows fail on main for these reasons:
- the template rows: main's `AGENTS-shape.md` and `README.md` lack the sentences;
- `_make_reads_first`: main has no such helper;
- the `CONTRACTS_DIR` line: "only once `GNUmakefile` does";
- the NOTE and collision rows: plain `python3`, and NIT-2's old tail;
- the two adoptions that keep the directory.

The one new row that passes on main is NIT-4's. It sends `GNUmakefile/` to the code leg, and there main's NEXT is already `make bootstrap`. It guards what main has: under the review's mutant X6, which hands NEXT every leg's paths, it is the row that fails.

The 19 rows of #1121's file that fail on main are exactly the rows that use the three pins this merge moved (`OWN_MAKEFILE_NOTE`, `RUNS`, `script_aside`). The 21 that pass use none of them.

Earlier heads, on main `961640c68` and with the same method: `1c7ca5c6d` failed 29 of 35 rows, and `8b499842f` failed 34 of 35 (the new file plus the three `tests/test_adopt_e2e.py` rows the mutants use).

**This round**, at `75c90b6db`, in a scratch worktree. Each mutant was applied alone and restored, and each file's sha256 was checked against the commit (4/4 every time). Each ran against 95 rows: the new file (35), `tests/test_adopt_e2e.py` (27) and `tests/test_adopt_make_reads_first.py` (33). Unmutated, all 95 pass.

| id | mutant | rows failing (of 95) | result |
|---|---|---|---|
| X1 | the review's: the script-only NOTE names `make bootstrap` after the merge (`if stops and makefile`) | 1 | killed |
| X6 | the review's: `cmd_execute` passes every leg's paths | 1 | killed |
| N1 | NIT-3 undone: beside a kept `Makefile`, no merge named | 2 | killed |
| N2 | the merge named where the script went aside too | 1 | killed |
| N3 | the merge named where no `Makefile` was kept | 4 | killed |
| T1 | NIT-1 undone: "(above)" back | 1 | killed |
| T2 | NIT-2 undone: README's `make park` / `make resume` sentence removed | 1 | killed |

The merge with #1121 rewrote the clause code that N1-N3 mutate (`stopped` became `reads`, and the merge condition gained `stops`). The mutants were not run again at `6fa1edd56`.

**Earlier,** 18 mutants at `1c7ca5c6d` against 43 rows, each applied alone in a scratch worktree and restored with its sha256 checked:

| id | mutant | rows failing (of 43) | result |
|---|---|---|---|
| M1 | `_make_reads_first` drops the `/` of a directory | 14 | killed |
| M2 | the clause's directory branch never taken | 10 | killed |
| M3 | NEXT ignores a kept directory (`stops = None`) | 6 | killed |
| M4 | NEXT's command stays `make bootstrap` for a directory | 4 | killed |
| M5 | `cmd_execute` passes `surviving=()` | 2 (the two adoptions) | killed |
| M6 | `BOOTSTRAP_COMMAND` without `(python on Windows)` | 12 | killed |
| M7 | NIT-2's tail back to "neither ... before both merges are made" | 2 | killed |
| M8 | `AGENTS-shape.md`'s "Work from here" caveat removed | 1 | killed |
| M9 | the sentence after the five-commands table removed | 1 | killed |
| M10 | `README.md`'s sentence removed | 1 | killed |
| M11 | #480's NOTE back to plain `python3` | 1 | killed |
| M12 | the collision follow-up's "until then" back to plain `python3` | 2 | killed |
| M13 | after the merges, NEXT says `make bootstrap` where a directory stops make | 1 | killed |
| M14 | the lookup takes the LAST kept name (`reversed`) | 4 | killed |
| M15 | the directory NOTE's lead ignores a kept `Makefile` | 1 | killed |
| M16 | the lookup folds case (`fold=True`) | 4 | killed |
| M17 | the clause drops GNU make's own words (`GNUmakefile: Is a directory.`) | 10 | killed |
| M18 | the file clause says `does` whatever `has` is | 0 | **survived** |

M18 was equivalent before the merge: the file clause's only caller was the `CONTRACTS_DIR` line. Since the merge, #1121's NOTE calls it with `has them`, and `tests/test_adopt_next_make_reads_first.py` pins that wording. M18 was not run again.

Each run went through the lane's runner: `gh` stubbed first on PATH with a bogus token, `GIT_SSH_COMMAND=false`, `GIT_CONFIG_GLOBAL=/dev/null`, `EMAIL` set, `-p no:cacheprovider`, and `tmp_path_retention_policy=failed`. Each run is on a commit, with a clean tree.

| run | commit | git | files | passed | failed |
|---|---|---|---|---|---|
| gate M | `6fa1edd56`, the merge | 2.43.0 | the new file, `test_adopt_next_make_reads_first.py`, `test_adopt_e2e.py`, `test_adopt_make_reads_first.py`, `test_path_guard_hygiene.py`, `test_repo_hygiene.py`, `test_agents_md_codes.py`, `test_cli_reference.py`, `test_pinned_copy_text.py`, `test_scaffold_leg_path_collisions.py` | 618 | 0 |
| gate N | `6fa1edd56` | 2.47.1 | the new file and `test_adopt_next_make_reads_first.py` (75), then `test_adopt_e2e.py` (27), run one after the other | 102 | 0 |
| gate H | `6fa1edd56` | 2.47.1 | the hygiene five | 379 | 0 |
| gate A2 | `75c90b6db` | 2.43.0 | the new file, `test_adopt_e2e.py`, the hygiene five (`test_path_guard_hygiene.py`, `test_repo_hygiene.py`, `test_agents_md_codes.py`, `test_cli_reference.py`, `test_pinned_copy_text.py`), `test_adopt_make_reads_first.py`, `test_adopt_contracts_dir.py`, `test_adopt_printed_sentences.py`, and the template's readers: `test_scaffold_e2e.py`, `test_scaffold_free_text_values.py`, `test_free_plan_hint.py`, `test_template_quoted_values.py`, `test_template_values_single_pass.py`, `test_template_text_placeholders.py`, `test_bootstrap_placement_texts.py`, `test_park_resume_targets.py`, `test_update_shape_hardlink.py` | 1128 | 0 |
| gate A | `1c7ca5c6d` | 2.43.0 | 17 files (the new file, `test_adopt_e2e.py`, the hygiene five, `test_scaffold_leg_path_collisions.py`, `test_adopt_make_reads_first.py`, `test_adopt_contracts_dir.py`, `test_adopt_printed_sentences.py`, `test_adopt_attributes_eol_block.py`, `test_adopt_leg_path_collisions.py`, `test_scaffold_e2e.py`, `test_bootstrap_placement_texts.py`, `test_park_resume_targets.py`, `test_template_text_placeholders.py`) | 966 | 0 |
| gate B | `1c7ca5c6d` | 2.47.1 | the new file, `test_adopt_e2e.py`, `test_path_guard_hygiene.py`, `test_repo_hygiene.py` | 209 | 0 |
| doctor | `1c7ca5c6d` | 2.43.0 | `test_shape_doctor.py`, `test_scaffold_leg_path_collisions.py` | 549 (3 skipped: the PowerShell rows, which run only on a Windows host) | 0 |

`tests/` was grepped for every line this PR changes in `templates/assembly-root/` ("They are the shape", "reads first holds", "includes a Makefile that", "(above)", "here and below", "Where this root keeps", "it is what the shape", "before `Makefile`", "`python` on Windows"). Only `tests/test_adopt_make_bootstrap_followups.py` pins them. Four other files read the README as a whole, and each passes in gate A2:
- `test_scaffold_free_text_values.py` counts its lines against the template;
- `test_free_plan_hint.py` looks for "Free plan" and `--repo`;
- `test_template_quoted_values.py` and `test_template_values_single_pass.py` render it.

`git merge-tree --write-tree` of the head `01e93b6d1`, on git 2.43.0, at 18:11Z.
- **Main** `9729315f1`, fetched again at 18:11Z, is the main this round merged last. The merge-tree is clean, and its tree is the head's own, `f6488542f`.
- **Main moved to `801a7d6d0`** at 18:14Z, when lane 3's #1106 landed (`adopt-project.py` and two locale test files). The merge with it is clean, tree `25bc27d39`, and gate P4 passed on it. It was not merged in: it touches none of the code this round resolves, and landing refreshes the branch anyway.
- **The open PRs:** one `gh pr list --state open --limit 100 --json number,headRefName,headRefOid,files` read at 18:11Z returned 51 open PRs. 26 of them touch one of this PR's paths. That includes `tests/test_adopt_collision_make_reads.py` and `tests/test_adopt_make_reads_first.py`, which this PR now changes. 25 merge cleanly: #1106, #1120, #1122, #1125, #1141, #1143, #1153, #1154, #1170, #1171, #1177, #1178, #1186, #1189, #1194, #1198, #1210, #1225, #1244, #1249, #1251, #1252, #1253, #1265 and #1268. #1106 has landed since (above).
- **Lane 1's #1189** (`472944b5d`, read fresh at 18:11Z) edits three test files that this round changes too: `tests/test_adopt_next_make_reads_first.py`, `tests/test_adopt_collision_make_reads.py` and `tests/test_adopt_make_reads_first.py`. The merge is clean, tree `7fd030b29`. #1189's hunks are in the imports, in the clone rows' parameter lists and docstrings, and in a new refusal row, away from the moved pins, the `makefile-directory` row and NIT-A's comment. On that predicted merge, a local commit object, the three shared files pass on git 2.43.0: `tests/test_adopt_make_reads_first.py` and `tests/test_adopt_collision_make_reads.py` give 62 passed, and `tests/test_adopt_next_make_reads_first.py` gives 38 passed. There are fewer rows than at this head because #1189 leaves out the clone rows that keep case twins.
- **#1237** (`b557859fd`) conflicts in `tests/test_adopt_check_throwaway_repos.py`, a file this PR does not change. Main conflicts with #1237 in that file too, while `6fa1edd56` did not, so the conflict is main's, carried in by the merge.
- **Main moved again after the round** (rv1207e, at 19:25Z): lane 1's #1143 landed as `81eaf757c` (`adopt-project.py`) and lane 4's #1117 as `9252ef208` (README, the handbook and `scripts/family.py`). The head merges clean with both (trees `e40373967` and `279f8c6ce`), and rv1207e's gate P passed on the predicted merge with `9252ef208` (359 passed). At 19:22Z, 48 PRs were open, 24 touch this PR's files, and 23 merge clean; #1237's conflict is main's, as above.
- **No longer on the list:** #1105, #1121, #1118 and #1123 are on main. Since `6fa1edd56`, #1104, #1160, #1169, #1180, #1190 and #1223 landed too.

The conflicts are the same in every order, measured offline both ways round and with predicted squashes:
- **#1121:** 4 hunks, 84 lines, in `adopt-project.py`'s `_next_steps` and `cmd_execute`'s comment.
- **#1105:** 3 hunks, 65 lines, in `scripts/shape_materialize.py`'s `collision_follow_up`: its docstring's NIT-4 sentence, its paragraph on the Makefile's merge, and its two `return`s.
- #1121 and #1105 merge with each other cleanly, and so do #1104 and this PR.

So the order decides only who resolves them. **Both have landed**, and lane 5 resolved both on this branch:
- **#1121** (merge `6fa1edd56`). The resolution is one lookup and one clause, `BOOTSTRAP_COMMAND` in #1121's NOTEs, and #1121's three test pins moved.
- **#1105** (merge `7b0192bde`, see "Main merge after #1105"). The resolution keeps #1105's `reads_first` branch and runs `BOOTSTRAP_COMMAND` through it. NIT-2's tail is this PR's where `make` reads the merged `Makefile`, and #1105's where `make` reads another file. Four of #1105's test pins moved: `MERGE_IS_ENOUGH`, `BOTH_MERGES`, `MEANWHILE` and `SCRIPT_MERGED`.

Main was merged in once more after lane 1's #1123 (merge `01e93b6d1`): one of #1123's rows pinned the line this PR changes for a kept `makefile/` directory, and it moved (see "The second merge, after #1123").

No other PR has to land first now. `6fa1edd56` was re-checked READY (rv1207b, rv1207c and rv1207d, issuecomment-6722602375). The head, `01e93b6d1`, needs a check of its delta since then: the two merges' resolutions, the four moved pins in #1105's file, #1123's moved row, and NIT-A.

#1240 tracks what this PR leaves:
- #1132's item 4 (one `GNU_MAKE_READS`, one lookup);
- #1105's collision line, for a kept directory (its `python3` part is done here: see "Main merge after #1105");
- #1121's file NOTE beside a kept `Makefile`, which does not name the merge (as this PR's directory NOTE now does);
- #1105's second review's NIT-1, NIT-3b, NIT-3c, NIT-4 and NIT-5;
- `_make_reads_first_clause`'s `has` argument, now live;
- rv1207e's NIT-1: the docstring sentence "With none, the Makefile's follow-up is what it was, byte for byte" (`scripts/shape_materialize.py` about :1067), kept from #1105, is no longer true, since this PR changes the line with no `reads_first`. It sits beside #1240's items F and G, which reword the same docstring.

The local branch `fix/1132-template-bootstrap-stacked` (`9eb5cce0b`, never pushed and never tested) is a model of the end state on #1105 + #1121 + main.

- **Item 5,** follow-ups that go stale after a hand edit of the plan, is its own issue, filed as #1206. It also holds the three related cases this work found:
  - a kept `makefile/` directory gets "until the two are merged";
  - a directory kept only through deeper entries is not seen by `_root_keeps`;
  - a kept `Makefile/` directory is treated as a Makefile.
- **This PR's `answered-root` row meets item 5 too.** `plan` asks about `GNUmakefile/`, and its stored `CONTRACTS_DIR` line, written before the answer, names no directory. The row asserts what NEXT and `make` do there, and not that line.
- **Not measured:** a disk that ignores case, and GNU make other than 4.3.

Review: rv1207b and rv1207c, lane 5's independent opus reviewers, and rv1207d, lane 5's independent sonnet reviewer, none of which wrote #1207: READY at `6fa1edd5` (issuecomment-6722602375). Then rv1207e, lane 5's independent opus reviewer, which wrote none of it: READY at `01e93b6d`, H0 of this landing, after the main merges past #1105 and #1123 (issuecomment-6726033282), with no MUST or SHOULD; its three NITs are answered in the body. CI (Brett Heap's ruling 27 and his fast-refresh ruling of 2026-10-15T22:48:35Z): H0 01e93b6 passed tests, tests-git-bash and SonarCloud; the head c9be952 is a clean update-branch merge of main 9cb156a, with tests-git-bash and SonarCloud green; and the local gate passed on its predicted squash tree 0a01d35 over main 9cb156a: the adopt_collision_make_reads, adopt_e2e, adopt_make_bootstrap_followups, adopt_make_reads_first, adopt_next_make_reads_first, repo_hygiene, agents_md_codes, cli_reference sets, 333 passed. Landed on Brett Heap's word of 2026-10-23T13:10:26Z, relayed to every lane by lane 3 (#473 issuecomment-6365697123): "merge v1.2.1 PRs once reviewed and green".

Closes #1132

Lane: openreposhape-5 (openRepoShape-5)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
brettheap added a commit that referenced this pull request Nov 10, 2026
…`, whatever `clone.defaultRemoteName` says, so `execute` no longer ends in `REFUSED mounting the legs` ("No such remote 'origin'") after both legs are pushed (#1261) (#1268)

`git clone` names the remote it makes after `clone.defaultRemoteName`,
and `adopt-project.py`'s `execute` addressed its clones as `origin`.
With `upstream` in the person's global git config,
`execute --local-remote-dir` ended in `REFUSED mounting the legs`, exit
2, `error: No such remote 'origin'`, after both legs were made and
pushed. With a name git refuses (`a..b`), `check` said
`adopt-git-unasked` and `execute` refused before any leg
(`fatal: 'a..b' is not a valid remote name`).

Each clone `execute` makes now names its remote `origin`, whatever the
person's config holds.
`REMOTE_NAMED_ORIGIN = ["-c", "clone.defaultRemoteName=origin"]` sits
beside `FILE_PROTOCOL`, and four git calls carry it: `_extract_leg`'s
`git clone` of the source (`git filter-repo` removes its `origin` by
name, and #1251's `git config --unset remote.origin.url` addresses it);
`_mount_the_legs`' `git submodule add`, the command that failed, whose
clone `git remote set-url origin <leg url>` then addresses; the
assembly's `git clone --template=` in `_commit_the_split`, which nothing
later addresses by name, covered so that every clone names its remote as
it does without the setting; and `check`'s rehearsal of the first clone
(`_split_clone_asked`), so that a name git refuses no longer fails
`check` where `execute` no longer reads it.

`Source.clone`, the `cloned: true` path, runs
`gh repo clone <org/repo> <dir> -- --quiet --origin origin`, since gh
runs git itself and no `-c` of ours reaches its clone; that argv is
pinned with a stub `gh` and not measured against a real one. The git
calls take the `-c` because `git submodule add` takes no `--origin`, and
under a global `upstream` it outranks a template's `config`,
`GIT_CONFIG_COUNT` and `GIT_CONFIG_PARAMETERS` (git 2.43.0). No flag or
command is added.

Under a global `upstream` or `a..b`, `plan`, `check` and `execute` all
exit 0 and say `adoption verified`. The legs pushed are `cmp`-identical
to a run without the setting, and so are the clones' remotes once each
run's base path is taken out: the assembly and both mounts `origin`, the
work clones none (filter-repo removes `origin`), where main's held
`remote.upstream.*`.

Not changed here: other tools that make a clone and then address it as
`origin`. `scaffold-project.py`'s `_build_assembly_root` runs
`git submodule add` and then `git remote set-url origin`, the shape of
the failing mount here, and it meets the same refusal: RV1268 measured
`--local-remote-dir` under `upstream` at exit 2, with
`error: No such remote 'origin'`. That is #1275; `setup-project.py` and
`setup.sh` drive it. `adopt-project.py`'s own reads of a source's
`origin` are #1276. Read but not probed, each a possible follow-up:
`setup-project.py`'s `origin_recorded_in`, `scripts/family.py`'s member
mount and its reads of `origin`, and `scripts/bump-leg.py`'s fetch of a
leg's `origin`.

`tests/test_adopt_clone_default_remote_name.py` (new) holds 6 rows, each
giving the setting to its own child only: at main's bytes of
`adopt-project.py` 4 fail and 2 pass (the premise row and the legs row,
since both legs were pushed before the mount refused), and here all 6
pass. `tests/test_adopt_source_clone_record.py`'s exact pin of the
`gh repo clone` argv gains `"--origin", "origin"`. With #1251 merged
there is one semantic conflict no merge shows: its row
`test_a_clone_with_no_origin_url_goes_on_to_filter_repo` set the global
`upstream` and expected the unset to exit 5, which now exits 0, so the
row sets `REMOTE_NAMED_ORIGIN` to `[]`, which makes the clone as main
did, and #1251's comment in `_extract_leg` now says no known cause
remains for that exit and the tolerance stays as a guard. All 5 mutants
(one per part) are killed. The 61 adoption modules whose tests run
`execute`, `tests/test_shape_doctor.py` (446 passed, 3 skipped) and
`tests/test_scaffold_leg_path_collisions.py` (104 passed) each pass, as
do the guards (349 passed, 3 skipped).

Closes #1261

Lane: openreposhape-3 (openRepoShape-3)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant