Skip to content

adopt-project.py: _unlisted_ref_directory (#1252) lists refs under reftable too, so check refuses source-unreadable a reftable source whose .git/refs this user cannot list, where git lists every ref and check said plan ok (rv1265 N1 on #1265; follows #1219 and #1257) #1291

Open

Description

@brettheap

(lane openRepoShape-3, 2026-11-09T22:05:03Z)

Found by: rv1265, lane 5's independent review (Opus) of PR #1265 (for #1257) at 59c6ecac, finding N1 (#1265 issuecomment-6724906723, relayed to lane 3 as asked in issuecomment-6724147738). It is filed on Brett Heap's word "file follow-ups 5, 10 and 15" (2026-11-09). It is on v1.2.2, the patch after v1.2.1, which adds no command and no flag.

It builds after #1252 lands. #1252 (for #1219) is lane 3's, on v1.2.1, and is not on main at filing (open, head 64a3d7d29). Its code is cited here from that head (git show of refs/pull/1252/head), so its line numbers move when it is squashed. The reach that makes the wrong refusal common comes from #1265 (for #1257; lane 3's, v1.2.1, open at filing, head 1a9782900; rv1265 reviewed 59c6ecac).

Lines for main are at 8cf6477fe, read and not run. Nothing was probed for this body, and reftable was not probed at all: this workstation's git is 2.43, and reftable needs 2.45 or later. The measurement is rv1265's, on git 2.47.1. This body is ASCII.

What is missing

A person can see it: check refuses a source it can read. A clone made on the reftable backend, whose .git/refs directory this user cannot list, is refused source-unreadable naming refs, though git lists all of its refs and exits 0. rv1265 measured it (N1, quoted exactly; "the head" is #1265's 59c6ecac, and b7a00b3 is #1265's base):

N1. A wrong refusal on a reftable source, newly reachable here. On git 2.47.1, a reftable clone with .git/refs at --x:

  • git lists all 4 refs and exits 0;
  • b7a00b3's check says plan ok (57 calls);
  • the head refuses source-unreadable: the source's refs ...: cannot be read (Permission denied), so the source's branches cannot be told (16 calls).

The cause is #1252's _unlisted_ref_directory, which lists refs even under reftable (its docstring says "nothing is listed"). Before this PR the walk ran only when the default branch was missing, which never happens here; now it runs in every check. The mode is contrived and reftable is opt-in, so this does not block. It could go to a #1252 follow-up: skip the walk where refs/heads is a file. refs/heads/.hidden (RV1252 N2) gets the same wider reach, and the body already says so.

rv1265's report opens "I measured everything on uid 1000 with real modes, git 2.43.0 and 2.47.1, Python 3.12.3." It does not say which of its probe files holds the reftable one (its folder is /workspace/projects/.lane-worktrees/openRepoShape-5/work/rv1265).

Why (the code, read and not run)

On main (8cf6477fe) none of it exists: _branch_names (adopt-project.py:3268) takes (path, prefix) and has no walk. At #1252's head 64a3d7d29:

  • _unlisted_ref_directory (adopt-project.py:3354). Its docstring, at :3370, says "Under a reftable refs/heads is a file, and nothing is listed." The code does not test for that before it lists:
    • :3372 at = PurePosixPath(target.parts[0]) starts at refs, the first part of refs/heads/ (BRANCH_REFS, :10561) and of refs/remotes/origin/ (ORIGIN_BRANCHES, :5235);
    • :3377 for name in _listed_names(common.joinpath(*at.parts)) or (): lists it; _listed_names (:3388) is os.scandir, and raises any refusal but "absent";
    • :3379-3381 asks whether an entry is a directory (_is_a(..., stat.S_ISDIR)) only after refs has been listed, so refs/heads being a file is learned too late;
    • :3384 return at, exc on any OSError. _refuse_unlisted_refs (:3331) turns it into source-unreadable, "the source's refs" and its path, "so the source's branches cannot be told" (BRANCHES_UNTOLD).
  • What the tool already knows of reftable. adopt-project.py:11056-11064 (REFTABLE_DIRS, REFTABLE_FILES): "the reftable backend keeps them (git 2.45 and later ... measured with git 2.47.1): a refs/heads that is a file, and reftable, whose tables hold every ref". That is the clone's own copy check, not the source's, but it is the same fact.
  • On adopt-project.py: a source whose refs this user cannot list is refused source-unreadable naming the directory, never source-default-branch-not-local "(its branches: none)" (#1219) #1252 alone the walk is rarely reached. _branch_names (:3321) asks only where the wanted branch is not among git's names; _symbolic_ref (:3288) only where git symbolic-ref -q exits other than 0 and 1; _tracking_branch_problem (:5282) only where the tracking branch is not among _branches_of's. Each is "asked only where git's answer was none", and on a reftable source git lists, so rv1265 says it "never happens here".
  • At adopt-project.py: a stale split branch in a source refs directory this user cannot list is refused source-unreadable by name, never plan ok from check or two legs made by execute (#1257) #1265's head 1a9782900 it is asked every time. _refuse_unlisted_refs_if_seen (:9896) calls _unlisted_ref_directory(common, prefix) from _branches_at (:9984) and _branches_in (:10138), which check and execute run for the split branch, "in every source no earlier run left one in" (its docstring). _common_dir_on_disk (:9920) gives .git for a .git directory, so for a reftable clone the walk lists .git/refs, as rv1265 saw.

The fix (as rv1265 framed it: "skip the walk where refs/heads is a file"; the writer settles the open choices)

Rows (they must fail before the change)

Not here

Done when

See #1219, #1252, #1257 and #1265.

Lane: openreposhape-3 (openRepoShape-3)

Activity

  1. added this to the v1.2.2 milestone on Nov 9, 2026
  2. brettheap commented on Nov 9, 2026

    @brettheap
    ContributorAuthor

    CLAIMED — lane openRepoShape-3, session b30e8b49-f249-4668-adb1-1dbfa93c09e1@Eagle, 2026-11-09T22:08:03Z, for #1291

    Logged in lanes/log/openRepoShape-3.md at 153e5b34fd339f6449ad6552b7434f195b7a4f33.

    The three reads (lane-collision-protocol Rule 1):

    1. existing `CLAIMED —` comments on opensoft/openRepoShape#1291:
       none
    2. `gh pr list --repo opensoft/openRepoShape --state all --search "#1291"`, kept where the row or its body names `#1291`:
       none
    3. `git ls-remote --heads [email protected]:opensoft/openRepoShape` branches naming `1291` as a whole token:
       none
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions