Skip to content

adopt-project.py: a reftable source whose .git/refs this user cannot list is read as git reads it, plan ok from check and adopted by execute, never refused source-unreadable naming refs (#1291) - #1324

Open
brettheap wants to merge 14 commits into
mainfrom
l3-1291-reftable-refs-not-walked
Open

brettheap wants to merge 14 commits into
mainfrom
l3-1291-reftable-refs-not-walked

Conversation

@brettheap

@brettheap brettheap commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

What changed

A v1.2.2 fix for #1291, which lane 3 filed on Brett Heap's word "file follow-ups 5, 10 and 15" (2026-11-09) from finding N1 of rv1265, lane 5's independent review of #1265. v1.2.2 is the patch Brett Heap opened on 2026-11-08T20:34:16Z ("yes freeze v1.2.1 and create v1.2.2"): no new command or flag, and its PRs land after the v1.2.1 tag, in the order lane 3 posts.

What a person sees change. A source git keeps on the reftable backend (git 2.45 and later), whose .git/refs this user can search and not list (mode --x), is read as git reads it again:

Nothing else changes. Every files-backend source prints the same bytes and runs the same git calls, call for call (measured below).

The change. _unlisted_ref_directory (adopt-project.py:3624), #1252's walk, returns None at once where the common git directory it is given holds both marks the reftable backend leaves (_keeps_refs_in_a_reftable, :3668): a refs/heads that is a FILE, and a reftable that is a directory. With one mark alone, or a stat refused, it walks as before. Every caller of the walk gets the answer:

The choice of test is written in _keeps_refs_in_a_reftable's docstring, and the reach of the skip in _unlisted_ref_directory's, where the next writer reads them.

The two choices, settled by measurement on git 2.47.1

git 2.47.1 built from kernel.org's tarball, its sha256 checked (see Gates). uid 1000, Python 3.12.3. Probe: W1291-scratch/gitprobe.sh.

What says "reftable": both marks, read on the common git directory the walk is given.

  • Every reftable repository git 2.47.1 made had both. A clone made with GIT_DEFAULT_REF_FORMAT=reftable, and a files clone made without reflogs and moved by git refs migrate --ref-format=reftable (git 2.47.1 refuses to migrate one with reflogs: migrating reflogs is not supported yet), each had .git/refs holding only heads, a regular file reading "this repository uses the reftable format", beside a .git/reftable directory, and extensions.refstorage = reftable. git's own reftable_be_create_on_disk (refs/reftable-backend.c in 2.47.1) writes both.
  • Each mark alone was met on the files backend, where git still lists loose refs in the directories under refs:
  • So both are asked. A source with neither, or one, is walked as today. git itself decides by extensions.refStorage in the repository's config, which the tool does not parse.
  • refs/heads is stated through refs, so it is read wherever refs can be searched, which is wherever git takes the directory for a repository at all: is_git_directory asks access(refs, X_OK). With refs at 000 or r--, git says fatal: not a git repository on either backend; the stat is refused, the helper says False, and the walk names refs as before.

How much of the walk to skip: all of it, for BRANCH_REFS and ORIGIN_BRANCHES.

Measured, before and after

Own probe (W1291-scratch/probe.py, built on W1257's): stub gh, --local-remote-dir, every mode put back, each source planned while readable and recorded as a clone plan made, and git calls counted by a logging wrapper. "Parent" is #1265's head 39b21c07, "after" is this head, and b7a00b3 is #1265's base. Rows 1 to 8 are reftable sources, on git 2.47.1; rows 9 to 15 are files-backend sources, run at the parent and after on git 2.43.0 and on git 2.47.1 with the same exits, refusals and call counts on both. The b7a00b3 column is git 2.47.1's.

# Source Verb b7a00b3 Parent 39b21c07 After
1 reftable clone, readable check / execute plan ok (57 calls) / adoption verified (101) plan ok (57) / adoption verified (103) the same as the parent, byte for byte
2 reftable clone, .git/refs at --x check plan ok, exit 0 (57) REFUSED source-unreadable, "the source's refs", exit 2 (16) plan ok, exit 0 (57): output and git calls equal b7a00b3's
2 the same execute adoption verified (101) REFUSED source-unreadable, refs, exit 2 (52) adoption verified, exit 0 (103)
3 row 2 with GIT_DEFAULT_REF_FORMAT=reftable for the tool's own repositories too check / execute plan ok / adoption verified REFUSED refs / REFUSED refs plan ok / adoption verified
4 reftable clone, .git/refs at 000 plan / check git-failed (not a git repository) / source-unclonable (main's .git/refs refusal came after b7a00b3) REFUSED source-unreadable naming .git/refs before any walk, 1 git call each the same as the parent, byte for byte
5 reftable clone, .git/refs at r-- check source-unclonable as row 4 the same as the parent
6 reftable clone, split branch in its own refs/heads/adopt, .git/refs at --x check FINDING adopt-branch-exists, exit 1 (58) REFUSED refs, "so the branches of the source's remote origin cannot be told" (18) FINDING adopt-branch-exists, exit 1 (58), equal to b7a00b3's
7 the same, split branch in refs/remotes/origin/adopt check FINDING adopt-branch-exists, exit 1 (58) REFUSED refs, "so the source's branches cannot be told" (16) FINDING adopt-branch-exists, exit 1 (58), equal to b7a00b3's
8 reftable clone, readable, with a refs/remotes/origin made by hand at 000 check plan ok (57) REFUSED naming refs/remotes/origin (18) plan ok (57), equal to b7a00b3's
9 files clone, readable plan / check / execute 18 / 57 / 101 calls, ok 20 / 57 / 103, ok the same as the parent, call for call
10 files clone, .git/refs at --x plan / check / execute REFUSED refs (6 calls each) REFUSED refs (6 each) the same
11 files clone, refs/heads at 000 check REFUSED refs/heads (6) the same the same
12 files clone, split branch, refs/heads/adopt at 000 check / execute plan ok / both legs pushed, then REFUSED pushing the split branch, exit 2 (93) REFUSED refs/heads/adopt (16 / 52) the same
13 files clone, split branch, refs/remotes/origin/adopt at --x check plan ok REFUSED refs/remotes/origin/adopt (18) the same
14 files clone with a .git/reftable made by hand (one mark), .git/refs at --x check REFUSED refs (6) REFUSED refs (6) the same
15 files source with refs/heads made a file (the other mark) plan, readable and at --x git-failed, show-ref --verify refs/heads/main (6) the same the same

Byte for byte, with temp-folder names normalised, parent against after:

The issue's first row asked for plan ok at 000 too. That cannot hold: with refs at 000 git takes the source for no repository, and the source is refused naming .git/refs before any walk, at the parent and after alike (rows 4 and 5).

Rows

13 rows in tests/test_adopt_tracking_branch.py, which holds #1219's and #1257's rows of this walk and the helpers they use (refs_at, refs_refused, unlisted_here, a_clone, planned_as_cloned, asked_of). The reftable mark and skip come from tests/test_adopt_root_symlinks.py (needs_reftable, refs_on_reftable, REF_FORMAT), so these rows make and skip a reftable repository as the repository's other reftable rows do.

Row Cases Parent 39b21c07 After
test_refs_git_can_search_and_not_list_are_asked_as_their_backend_reads reftable x check, execute: a reftable clone, .git/refs at --x. Skipped before git 2.45, as root and on Windows 2 fail (source-unreadable, refs) pass on 2.47.1
the same files x check, execute: control, still refused naming refs pass pass
test_a_reftable_common_directory_is_not_walked a hand-made common git directory with both marks; refs refused to os.scandir (as at --x), for refs/heads/ and refs/remotes/origin/, and a stray refs/remotes/origin refused. Runs on any git, as root and on Windows 3 fail (the refused directory named) pass
test_a_common_directory_with_one_reftable_mark_is_walked_as_before control: refs/heads a file alone, or reftable alone, x both prefixes: refs named with EACCES pass pass
test_a_reftable_common_directory_git_cannot_search_is_walked_as_before control: both marks, refs at 000, x both prefixes: refs named pass pass

Against the parent's adopt-project.py: 5 failed, 8 passed on git 2.47.1, and 3 failed, 8 passed, 2 skipped on git 2.43.0 (the reftable cases skip there).

The files-backend refusals are held by existing rows, unchanged and passing: test_a_clone_whose_refs_git_can_search_and_not_list_is_named (refs at --x, plan), test_a_clone_whose_branches_git_cannot_list_is_refused_by_name (refs/heads at 000, --x and r--), test_a_remote_whose_branches_git_cannot_list_is_named (refs/remotes/origin), and test_a_split_branch_git_cannot_list_is_refused_by_check (#1257's).

Mutants

Own script (W1291-scratch/mut.py): each mutant written into adopt-project.py, the 13 rows run on git 2.47.1, the file restored and checked with cmp against the fixed copy (cmp OK after each).

Mutant Result Rows that failed
M0: the parent's adopt-project.py KILLED, 5 failed both reftable CLI rows, the 3 hand-made reftable rows (on git 2.43.0: the 3 hand-made rows)
M1: the skip taken out KILLED, 5 failed the same 5 (on git 2.43.0: the same 3)
M2: refs/heads a file alone says reftable KILLED, 2 failed ..._one_reftable_mark_...[heads-file-alone-own], [heads-file-alone-fetched]
M3: a reftable directory alone says reftable KILLED, 4 failed ..._one_reftable_mark_...[reftable-alone-*], ..._git_cannot_search_...[own], [fetched]
M4: the skip for refs/heads/ only KILLED, 3 failed ..._backend_reads[reftable-check], ..._is_not_walked[refs-fetched], [stray-origin-fetched]
M5: the skip of refs only, the walk going on from refs/heads or refs/remotes KILLED, 1 failed ..._is_not_walked[stray-origin-fetched]
M6: a refused stat read as reftable KILLED, 2 failed ..._git_cannot_search_...[own], [fetched]

The mutants ran before a reflow of one docstring; the code is the same, by ast with docstrings taken out.

Gates

Gated commit: bb81493a, a local commit never pushed, with a clean tree before and after. This head, e9798fab, differs from it only in tests/test_adopt_tracking_branch.py, where one import moved below the next, under a comment, so that #1312 and #1321 merge clean (see Merges). adopt-project.py is the same bytes. The tracking module and test_adopt_github_exits.py, which imports from it, ran again on this head: 114 passed in 124.79s on git 2.47.1, and 112 passed, 2 skipped in 131.55s on git 2.43.0 (the 2 reftable cases). Each run is /usr/bin/python3 -m pytest -q -p no:cacheprovider -rs, one pytest at a time, uid 1000, Python 3.12.3. Each runs with a stub gh (exit 97) first on PATH, then git-filter-repo 2.47.0 (CI's pin); GH_TOKEN=bogus, an empty GH_CONFIG_DIR, GIT_SSH_COMMAND=false, GIT_CONFIG_GLOBAL=/dev/null, and LANES_LANE unset. Each group ran twice: on the bench's git 2.43.0, and with git 2.47.1 first on PATH after the stub and filter-repo.

git 2.47.1 was built for this:

  • Source: https://mirrors.edge.kernel.org/pub/software/scm/git/git-2.47.1.tar.xz.
  • Its sha256, f3d8f9bb23ae392374e91cd9d395970dabc5b9c5ee72f39884613cd84a6ed310, was checked against kernel.org's sha256sums.asc: git-2.47.1.tar.xz: OK. That file's signature could not be checked here, as the bench has no key for it.
  • Build: make -j16 prefix=<lane 3's tools folder> NO_CURL=1 NO_OPENSSL=1 NO_GETTEXT=1 NO_TCLTK=1 NO_PYTHON=1 NO_PERL=1 install.
  • git --version: git version 2.47.1.
Run git 2.47.1 git 2.43.0
The rows' area, in one pytest. test_adopt_tracking_branch.py, with test_adopt_github_exits.py (which imports from it), test_adopt_root_symlinks.py and test_adopt_unsearchable_source.py (which it imports from). The source-unreadable modules that run adopt-project.py: test_adopt_pins.py, test_adopt_plan_partial_clone.py (with test_adopt_partial_clone_source.py, its fixtures), test_adopt_unenterable_source_and_locale.py, test_adopt_unreadable_clone_git.py, test_adopt_unreadable_git_parts.py and test_pin_source_unreadable.py. Then test_adopt_split_branch.py and test_scaffold_leg_path_collisions.py 914 passed in 986.85s 909 passed, 5 skipped in 898.82s
Guards: test_repo_hygiene.py, test_cli_reference.py, test_agents_md_codes.py, test_git_output_decoding.py, test_stdout_encoding.py, test_path_guard_hygiene.py, test_no_auto_maintenance.py, test_update_add_codes_documented.py 470 passed, 3 skipped in 92.63s 470 passed, 3 skipped in 85.48s
tests/test_shape_doctor.py (in the background, with a log) 446 passed, 3 skipped in 728.89s 446 passed, 3 skipped in 728.28s

Skips:

Also checked:

  • The 13 new rows alone: 13 passed on git 2.47.1; 11 passed and 2 skipped on git 2.43.0.
  • flake8 reports the same 36 findings in the two changed files before and after.

Not run:

  • The other 12 modules that grep source-unreadable. They test other tools' code of that name (pins, scaffold, setup-project.py) and never run adopt-project.py.
  • The full suite, Python 3.14, Windows, and a root run. The mode rows are under needs_a_mode; the hand-made rows run as root.

Merges

git merge-tree --write-tree of this head with main, and with each open PR that touches adopt-project.py or tests/test_adopt_tracking_branch.py, and the same of #1265's head alone. The heads were fetched by URL and checked against gh pr list, read before the gates and again after them, at 19:44Z (#1171 had landed by then; #1209, #1321 and #1322 were new).

Stacked, then restacked

Stacked on #1265 (head 39b21c07ea3e6a4a1608299df201786cc5431e22); this PR's own change is 39b21c07..e9798fab. Review that range.

#1265 landed at 22:10Z on 2026-11-10 as dcf63b8b. Lane 3 then restacked this PR onto its squash with two merges (restack-1324.sh): #1265's final head 9eecc2da, then the squash dcf63b8b, taking ours for this PR's own file that conflicted (tests/test_adopt_tracking_branch.py). Main was the squash, so no third merge was needed.

  • The new head 93424b9c has tree f2b5ba54e: the tree of this PR's own range applied to the squash (git merge-tree --write-tree --merge-base 39b21c07 dcf63b8b e9798fab).
  • Its 193 own no-context lines over the squash equal those of e9798fab over 39b21c07 (cmp), so the restack changed none of the reviewed lines.

Out of scope (seen, not changed)

Independent review

RV1291, lane 3's independent opus review (issuecomment-6778652036), reads READY at e9798fab, with no MUST and no SHOULD. It judged all three choices right:

  • what says "reftable": both marks. Every reftable repository git 2.47.1 makes holds both, and each mark alone is met on the files backend, where git still lists loose refs;
  • skipping the whole walk, for both prefixes: under reftable, git never reads a directory under refs;
  • the departure: a reftable clone with .git/refs at 000 or r-- is no repository to git (fatal: not a git repository), and the tool refuses it naming .git/refs before any walk, the same bytes before and after.

Its own probe, 74 runs on git 2.47.1 and 43 on git 2.43.0, found every changed output to be what #1291 asks, and every other output the same but for temporary names and the hashes of the tool's own revision. The 13 rows: 13 passed on git 2.47.1, and 11 passed with 2 skipped on git 2.43.0. With the parent's adopt-project.py, 5 failed on git 2.47.1 and 3 on git 2.43.0. Its mutants R2 and R3 were killed. Its gates at e9798fab:

  • tests/test_adopt_tracking_branch.py, tests/test_adopt_github_exits.py, tests/test_adopt_unsearchable_source.py and tests/test_adopt_root_symlinks.py in one run: 367 passed on git 2.47.1; 362 passed, 5 skipped on git 2.43.0;
  • the guards: 470 passed, 3 skipped on each git;
  • tests/test_scaffold_leg_path_collisions.py: 104 passed, and tests/test_shape_doctor.py: 446 passed, 3 skipped, on git 2.43.0.

Lane 3 checked the one thing RV1291 could not: bb81493a differs from e9798fab only in tests/test_adopt_tracking_branch.py, by the moved import (3 insertions, 2 deletions), so the area gate on bb81493a stands for this head.

Taken here: N2 to N6, all in this body.

Not taken: N1, an optional row for a common directory with reftable and no refs/heads. git makes no such repository, and RV1291's mutant R1 differs from the head only there. It is a follow-up candidate for Brett Heap.

Closes #1291

Lane: openreposhape-3 (openRepoShape-3)

🤖 Generated with Claude Code

Summary by Sourcery

Read reftable-backed sources according to Git's ref storage behavior so searchable but unlistable .git/refs directories no longer cause false adoption refusals.

Bug Fixes:

  • Handle reftable-backed Git sources whose .git/refs directory is searchable but not listable without incorrectly reporting source-unreadable.
  • Allow check to produce a valid plan and execute --local-remote-dir to adopt reftable sources while preserving existing files-backend behavior.

Enhancements:

  • Skip filesystem ref-directory checks when the common Git directory has the markers for Git's reftable backend, while continuing to walk ambiguous or inaccessible layouts as before.

Tests:

  • Add coverage for reftable and files backends, inaccessible ref directories, mixed backend markers, and both local and remote branch ref walks.

Brett Heap and others added 11 commits November 8, 2026 14:03
…sed `source-unreadable` naming the directory, never `source-default-branch-not-local` "(its branches: none)" (#1219)

git passes over a directory of refs it cannot list (for-each-ref exits 0)
and says "No such ref" (symbolic-ref -q exits 128) of a ref it cannot
reach. Where git's answer is none, `_branch_names`, `_symbolic_ref` and
`_tracking_branch_problem` now ask whether each directory git lists was
listable, and refuse `source-unreadable` naming the one that was not, with
the `chmod` cure. A source git reads whole asks nothing more.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ranch-readers

#1257 builds on #1252's _refuse_unlisted_refs; this branch carries #1252's commit until #1252 lands.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…s user cannot list is refused `source-unreadable` by name, never `plan ok` from `check` or two legs made by `execute` (#1257)

`_branches_at` and `_branches_in`, which feed the split-branch finding
`adopt-branch-exists` and `execute`'s refusals of an earlier run's split
branch, listed the source's refs with `git for-each-ref` alone, which
passes over a directory it cannot list and exits 0. Measured on #1252
merged into main (b7a00b3): with an earlier run's
`adopt/three-repo-shape` in `.git/refs/heads/adopt` at mode 000 or
`--x`, `check` said `plan ok`, exit 0, and `execute --local-remote-dir`
made and pushed both legs before its split push met the branch; with
it in `.git/refs/remotes/origin/adopt`, `check` said `plan ok`.

Each reader now takes the split branch, `wanted`, and where git's list
lacks it asks whether git could list each directory of the prefix it
read (`_refuse_unlisted_refs_if_seen`): one it could not is
`source-unreadable`, naming it, with the `chmod u+rx` cure, through
#1252's `_refuse_unlisted_refs`. A readable source lacks the split
branch most often, so the directories are read from the disk first,
from the common git directory `_common_dir_on_disk` finds as git finds
it, and git is asked only where the disk shows one it cannot list or
cannot say where the refs are: a readable source runs the same git
calls as before (plan 18, check 57, execute 101).

Every caller passes the split branch: `_places_in_the_source`,
`_places_check_asks`, `_refuse_a_branch_in_the_split_branchs_way` and
`_refuse_a_split_branch_left_behind`.

Rows at the end of tests/test_adopt_tracking_branch.py, beside #1219's.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…mon_dir_on_disk's NUL case (rv1265 N2, N3)

Two NITs of lane 5's independent review of #1265 (rv1265, at 59c6eca),
which found it READY with no MUST or SHOULD.

N2. `_refuse_unlisted_refs_if_seen` acts on the disk's guess at the common
git directory (`_common_dir_on_disk`) only by asking git, so a guess that
is wrong or missing costs a miss or one more `git rev-parse`, never a
refusal of its own. Five mutants of that guess survived the 20 rows of
#1257. Six rows now pin it. Each makes the common git directory's
`refs/heads/adopt` a directory the process cannot list (in-process, as
root and on Windows too), asks `_branches_at` for the split branch, and
requires `source-unreadable` naming that directory as git names it.

- test_the_disk_places_a_relative_or_crlf_git_file_where_git_does[submodule]:
  a submodule's `.git` file, `gitdir: ../.git/modules/sub`, read from
  another folder. It must name the clone's `.git/modules/sub` as git does.
  Kills R1, a relative gitfile joined to the cwd.
- ...[crlf-gitfile]: a linked worktree's `.git` file ending in CR LF. Kills
  R6, the CR kept on the gitfile's line.
- test_a_source_the_disk_will_not_place_is_asked_of_git_and_refused, which
  also requires the guess to be None:
  - [nul-gitfile], a `.git` file holding a NUL (git reads it up to the NUL):
    kills R3, the gitfile NUL check dropped.
  - [nul-commondir], a `commondir` file holding a NUL: kills R4, the
    `commondir` NUL check dropped.
  - [git-dir-set]: kills R8, a None guess asking nothing, as do the other
    three.
  - [git-common-dir-set]: also kills GIT_COMMON_DIR not heeded, which
    test_the_disk_is_not_read_where_git_would_not_read_it kills too.
- refs_refused takes `common=` for a git directory that is not the
  source's `.git`; its other callers are unchanged.

Each mutant, applied alone to adopt-project.py with the 20 rows and these
six run: R1, R3, R4 and R6 fail one row each, R8 four, and all survive
the 20 rows alone.

N3. `_common_dir_on_disk`'s docstring said it returns None where either
file holds "what git would not read so (... a NUL)". git reads a gitfile or
`commondir` holding a NUL up to the NUL, and succeeds. The docstring now
says the function declines to guess where a file holds a NUL, and git is
asked. No code changed.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…ck; ours for tests/test_adopt_tracking_branch.py, whose squash equals #1252's final head)

Lane: openreposhape-3 (openRepoShape-3)

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…d merge; main moved past #1252's squash by two landings that touch none of this PR's files)

Lane: openreposhape-3 (openRepoShape-3)

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…t list is read as git reads it, `plan ok` from `check` and adopted by `execute`, never refused `source-unreadable` naming `refs` (#1291)

#1252's `_unlisted_ref_directory` listed `refs` even where git keeps the
refs in a reftable and lists no directory under `refs`. #1265 asks that
walk for the split branch in every `check` and `execute
--local-remote-dir`, so a reftable clone with `.git/refs` at `--x`, every
ref of which git 2.47.1 lists with exit 0, was refused
`source-unreadable`, "the source's `refs`".

The walk is now skipped whole, for the source's own branches and for
`origin`'s, where the common git directory holds both marks the reftable
backend leaves: a `refs/heads` that is a file and a `reftable` directory
(`_keeps_refs_in_a_reftable`). With one mark alone, or a `stat` refused,
it walks as before, so every files-backend refusal stays.

Lane: openreposhape-3 (openRepoShape-3)

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

sourcery-ai Bot commented Nov 10, 2026 •

Copy link
Copy Markdown

Reviewer's Guide

Implementation

Detect reftable storage from both on-disk markers and skip the ref-directory walk entirely, because Git reads reftable refs without listing directories under refs.

  • adopt-project.py L3711-3721, L3739-3762

Tests

Add regression and control tests for reftable detection, whole-walk skipping, refused stats, and unchanged files-backend behavior.

  • tests/test_adopt_tracking_branch.py L52-58, L79-81, L1408-1548

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

(lane openRepoShape-3, 2026-11-10T20:37:18Z) RV1291: READY at e9798fa

I review only the PR's own commit, 39b21c07..e9798fab (adopt-project.py, tests/test_adopt_tracking_branch.py). I wrote none of #1324. I measured everything below as uid 1000 with Python 3.12.3, on the bench's git 2.43.0 and on git 2.47.1 at /workspace/projects/.lane-worktrees/openRepoShape-3/git-2.47.1/bin/git. That tarball's sha256 is f3d8f9bb...a6ed310, the same as the body and sha256sums.asc; the gpg signature is not checked. Every run had a stub gh (exit 97) first on PATH, then git-filter-repo 2.47.0, with LANES_LANE unset, GH_TOKEN=bogus, GIT_SSH_COMMAND=false and GIT_CONFIG_GLOBAL=/dev/null. I used my own probes, not W1291's.

The three choices

1. What says "reftable" (both marks): RIGHT, and the measurements are true. On git 2.47.1:

  • Every reftable repository git makes has both marks. .git/refs holds only heads, a file reading this repository uses the reftable format, beside a .git/reftable directory. I saw this for init --ref-format=reftable (bare and not bare), clone --ref-format=reftable, GIT_DEFAULT_REF_FORMAT=reftable clone, and a linked worktree's own git directory.
  • refs migrate gives both marks too, but only for a clone made without reflogs. With reflogs, 2.47.1 refuses: error: migrating reflogs is not supported yet, exit 255.
  • git's source agrees. reftable_be_create_on_disk in refs/reftable-backend.c (lines 383-397) makes reftable/ and writes refs/heads as a file.
  • Each mark alone is met on the files backend, where git still lists loose refs:
    • A files clone with a hand-made .git/reftable and refs at --x: for-each-ref refs/heads/ printed nothing, exit 0, though main and adopt were loose there.
    • A files clone with refs/heads made a file and refs at --x: for-each-ref refs/remotes/origin/ left out a loose origin/adopt. Readable, it listed it.

2. How much to skip (the whole walk, both prefixes): RIGHT.

  • Under reftable, git never reads a directory under refs. In a reftable clone with a hand-made refs/remotes/origin at 000 holding a loose stray, git listed origin/HEAD, dev and main from the tables, exit 0. It did the same with refs at --x, and once the stray directory was made readable it still never listed stray.
  • With refs at --x or -wx, git listed every ref under both refs/heads/ and refs/remotes/origin/, from the clone and from its linked worktree.
  • In the tool: the stray-directory source goes from REFUSED naming refs/remotes/origin (18 git calls) at the parent to plan ok (57) after.

3. The departure: TRUE, and the body says it plainly.

  • A reftable clone with .git/refs at 000 or r-- makes git 2.47.1 say fatal: not a git repository, exit 128, because is_git_directory asks access(refs, X_OK) (setup.c:447-448).
  • The tool refuses it source-unreadable, naming .git/refs, with 1 git call, before any walk. For plan, check and execute at 000, and plan and check at r--, the parent and the head are byte-identical.
  • The body says this in "Measured" ("The issue's first row asked for plan ok at 000 too. That cannot hold...") and again in "Out of scope".

Before and after (own probe; parent 39b21c07 against head e9798fab)

Each source was planned while readable and recorded as a clone plan made. Each run used --local-remote-dir, git calls were counted by a logging wrapper, and every mode was put back.

Source Verb Parent Head
reftable, refs at --x check / execute REFUSED refs (16 / 52) plan ok (57) / adoption verified (103)
reftable, refs at -wx check REFUSED refs (16) plan ok (57)
the same, with GIT_DEFAULT_REF_FORMAT=reftable for the tool too check / execute REFUSED (16 / 52) plan ok (57) / adoption verified (103)
reftable, own split branch, refs at --x check REFUSED refs, "...remote origin cannot be told" (18) FINDING adopt-branch-exists, exit 1 (58)
reftable, fetched split branch, refs at --x check REFUSED refs, "the source's branches" (16) FINDING adopt-branch-exists (58)
reftable, stray refs/remotes/origin at 000 check REFUSED naming it (18) plan ok (57)
linked worktree of a reftable clone, common refs at --x check / execute REFUSED main-clone/.git/refs (16 / 52) plan ok (57) / adoption verified (103)
reftable, refs at 000 / r-- plan / check / execute REFUSED .git/refs (1 call) same bytes
reftable, readable; own split branch, readable check / execute ok (57 / 103); FINDING (58) same
  • git 2.47.1, files backend (refs, refs/heads and refs/remotes/origin at 000, --x and r--; split branches; each mark alone; both marks made by hand; a files linked worktree): every output and every git call log is identical. The only differences are mkdtemp suffixes and, in the readable execute, hashes that come from the tool's own revision (its ls-tree of 39b21c0 or e9798fa, and the split commit made from it).
    • The one files-backend source the skip can fire on is both marks made by hand. It is git-failed at show-ref --verify refs/heads/main (6 calls) at the parent and at the head alike.
    • Totals: 186 of 222 files identical over 74 runs. The rest are the 10 changed runs above and those revision hashes.
  • git 2.43.0, files cases: 127 of 129 files identical over 43 runs. The 2 that differ are the readable execute's revision hashes.
    • A reftable source made by 2.47.1 and read under 2.43 is unknown repository extension found: refstorage. Both versions then refuse it source-unclonable the same way.
  • Body numbers: every call count I re-measured matches the body's table (16/52/57/101-103/18/58/6/1/20), and the "untold" wording of rows 6 to 8 matches.

Rows (13 new)

Run git 2.47.1 git 2.43.0
At the head 13 passed in 6.52s 11 passed, 2 skipped in 2.16s (:1434, needs 2.45)
Parent's adopt-project.py swapped in (restored, cmp OK) 5 failed, 8 passed 3 failed, 8 passed, 2 skipped

On 2.47.1 against the parent, the failures are ..._backend_reads[reftable-check], [reftable-execute], and ..._is_not_walked[refs-own], [refs-fetched], [stray-origin-fetched]. This matches W1291.

The imports from test_adopt_root_symlinks are a marker, a string and a function, not fixtures, so the #1188 hazard does not apply. The gate below runs both modules in one pytest anyway.

Mutants (my own; each restored and checked with cmp, 13 rows on 2.47.1)

Mutant Result
R1: a refs/heads that is not a directory, absent included, counts as the mark SURVIVED, 13 passed (see N1)
R2: a refused stat of a mark is raised, not read as "walk" KILLED, 2 failed: ..._git_cannot_search_...[own], [fetched]
R3: marks asked only after a refusal, and only where that refusal is at refs itself KILLED, 1 failed: ..._is_not_walked[stray-origin-fetched]

Gates at e9798fa (one pytest at a time, -rs, clean tree before and after)

Run Result
test_adopt_tracking_branch.py, test_adopt_github_exits.py, test_adopt_unsearchable_source.py, test_adopt_root_symlinks.py, git 2.47.1 367 passed in 459.21s
the same, git 2.43.0 362 passed, 5 skipped in 452.81s (tracking :1434 x2; root_symlinks :1960, :2015, :2596, all "needs git 2.45")
Guards (repo_hygiene, agents_md_codes, git_output_decoding, stdout_encoding, cli_reference, path_guard_hygiene, no_auto_maintenance, update_add_codes_documented), git 2.43.0 470 passed, 3 skipped in 94.95s
the same, git 2.47.1 470 passed, 3 skipped in 87.52s
test_scaffold_leg_path_collisions.py, git 2.43.0 104 passed in 5.01s
test_shape_doctor.py, git 2.43.0 446 passed, 3 skipped in 783.58s (:10516 x3, Windows only)
  • flake8: 36 findings at the parent and at the head, the same findings.
  • SonarCloud: gate OK. Its 4 open issues (adopt-project.py:2356, tracking :1165, :1184, :1227) are outside this PR's hunks.
  • CI: tests is still pending on e9798fa. package, tests-git-bash and SonarCloud pass.
  • Does W1291's re-gate suffice? I could not check that e9798fab differs from bb81493a only by the moved import: bb81493a is not on GitHub (No commit found for SHA: bb81493a, HTTP 422). My own gates above cover the head's adopt-project.py in its own modules, the import chain, the guards, collisions and the doctor. The other area modules import nothing from the tracking module, so I judge the area gate sufficient. They were not re-run at this head. If lane 3 wants them, the command is below.

Merges (git merge-tree --write-tree)

Body

  • Closes #1291 is the only closing keyword, with no bot section, and closingIssuesReferences reads [1291].
  • It is ASCII except U+1F916 on the robot line.
  • It covers what a person sees change, the choices, the departure, the git build and the restack plan.

Findings

MUST: none. SHOULD: none.

NIT N1 (row, optional). R1 survives because no row has a common directory with reftable and no refs/heads. On every repository git makes, R1 behaves the same (git always makes refs/heads). A fifth case, reftable without refs/heads walked as before, in test_a_common_directory_with_one_reftable_mark_is_walked_as_before would pin the docstring's "a refs/heads that is a FILE".

NIT N2 (body, Out of scope). Add after the "reftable directory is gone" bullet:
"- A reftable repository whose refs/heads file is gone: git 2.47.1 lists every ref with refs at --x, exit 0. It holds one mark, so the walk runs as before and names refs, as at #1265's head. It is a broken repository, not a mode."

NIT N3 (body). Replace "38 of 38 files identical, the stdout, stderr and git call log of each of the 19 runs (rows 9 to 15)." with:
"38 of 38 files identical: for each of the 19 runs (rows 9 to 15), one file with its exit, stdout and stderr, and one with its git call log."

NIT N4 (body). Replace "and a files clone moved by git refs migrate --ref-format=reftable," with:
"and a files clone made without reflogs and moved by git refs migrate --ref-format=reftable (git 2.47.1 refuses to migrate one with reflogs: migrating reflogs is not supported yet),"

NIT N5 (body, Gates). Replace "Gated commit: bb81493a, with a clean tree before and after." with:
"Gated commit: bb81493a, a local commit never pushed, with a clean tree before and after."

NIT N6 (body, Merges). #1237 has landed as main f7f34fb0. Replace "Clean with #1237, #1249," with "Clean with #1249,". Then add:
"- This head + main f7f34fb0 (#1237 landed): clean, tree b256a6781ef9."

Paths and what is left

  • Clone: /workspace/projects/openRepoShape-worktrees/_lane3-scratch/RV1291, detached at e9798fa, clean. Its linked worktree RV1291-scratch/wt-parent is at 39b21c0.
  • Scratch: /workspace/projects/openRepoShape-worktrees/_lane3-scratch/RV1291-scratch
    • git facts: gitfacts.sh, gitfacts-247.txt, gitfacts-243.txt, gitfacts-migrate-247.txt
    • before/after probe: probe.py, probe-all.sh, probe-out2/, probe-summary.txt, rt-under-243.sh
    • rows and mutants: rows.sh, mutate.py, mut-*.log
    • gates: gates.sh, gates.log, gate-*.log
    • CHECKPOINT.md
  • Not run at this head: the doctor under git 2.47.1 (it passed under 2.43.0), and the area modules outside the import chain, under either git. Commands:
    • cd /workspace/projects/openRepoShape-worktrees/_lane3-scratch/RV1291 && /workspace/projects/openRepoShape-worktrees/_lane3-scratch/RV1291-scratch/envrun-git247.sh /dev/null /usr/bin/python3 -m pytest -q -p no:cacheprovider -rs --basetemp=/tmp/claude-1000/l3bt/RV1291-doctor-247 tests/test_shape_doctor.py
    • cd /workspace/projects/openRepoShape-worktrees/_lane3-scratch/RV1291 && /workspace/projects/openRepoShape-worktrees/_lane3-scratch/RV1291-scratch/envrun.sh /dev/null /usr/bin/python3 -m pytest -q -p no:cacheprovider -rs --basetemp=/tmp/claude-1000/l3bt/RV1291-area-243 tests/test_adopt_pins.py tests/test_adopt_plan_partial_clone.py tests/test_adopt_partial_clone_source.py tests/test_adopt_unenterable_source_and_locale.py tests/test_adopt_unreadable_clone_git.py tests/test_adopt_unreadable_git_parts.py tests/test_pin_source_unreadable.py tests/test_adopt_split_branch.py
    • For git 2.47.1, run the second command with envrun-git247.sh and basetemp RV1291-area-247.
  • I did not re-run W1291's own mutants M1 to M6.

Lane 3: READY stands. Lane 3 measured the one thing RV1291 could not. bb81493a, the gated commit, is in W1291's clone and differs from e9798fab only in tests/test_adopt_tracking_branch.py, by the moved import (3 insertions, 2 deletions); adopt-project.py is the same bytes. So W1291's area gate on bb81493a, under both gits, stands for this head.

  • The doctor under git 2.47.1 is not run again: RV1291's doctor run under git 2.43.0 skipped no row for want of git 2.45, so no doctor row makes a reftable repository, and git 2.47.1 still makes the files backend by default.
  • Taken now, in the body: N2 to N6, as RV1291 words them.
  • Not taken: N1, an optional row for a common directory with reftable and no refs/heads. git makes no such repository, and R1 differs from the head only there. It goes on the list of follow-up candidates for Brett Heap.

@brettheap brettheap added this to the v1.2.2 milestone Nov 10, 2026
@brettheap
brettheap marked this pull request as ready for review November 10, 2026 20:38
@brettheap

Copy link
Copy Markdown
Contributor Author

@sourcery-ai

sourcery-ai Bot commented Nov 10, 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 4 days and 17 hours by commenting @sourcery-ai review. Upgrade to get a review now.

brettheap and others added 3 commits November 10, 2026 17:03
Lane: openRepoShape-3

Co-Authored-By: Claude Opus 5.5 <[email protected]>
… that conflicted

The PR's own no-context lines over the squash equal its lines over #1265's head 39b21c0, and the tree is f2b5ba5, the tree of this PR's own range applied to #1265's squash.

Lane: openRepoShape-3

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

Copy link
Copy Markdown
Contributor Author

(lane openRepoShape-3, 2026-11-10T23:19:52Z) Restacked after #1265 landed. The new head is 93424b9c, from two merges: #1265's final head 9eecc2da, then its squash dcf63b8b, taking ours for this PR's own file that conflicted.

@sonarqubecloud

Copy link
Copy Markdown

This branch has not been deployed

No deployments
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