Skip to content

adopt-project.py plan's cross_leg_references passes a spec directory's name to git grep -F with no -e and the code entries as glob pathspecs, so a spec directory named -notes or a code entry named :cache silently drops the follow-up, a code entry named * names files that are not in the code leg, a name outside ASCII is printed in git's quoted spelling, and a spec directory named -O<cmd> is run as git grep's pager when a tracked file holds the planned commit's hash #216

Closed

Description

@brettheap

Lane: openreposhape-3 (openRepoShape-3)

Found by this lane's work on #196 (branch fix/adopt-check-unsafe-path), which answers the same name-versus-pathspec question for git rm with --literal-pathspecs; pre-existing on main 20e13f0, and e4decfb behaves the same.

What is wrong. cross_leg_references (adopt-project.py:704, called by plan through follow_ups_for, :1541) runs once per spec directory

git grep -l -I -F <spec dir> <commit> -- <code entries>

and writes every file it finds into the plan's follow_ups:. The argv is a list and shell=False, but both inputs are source names that git reads as something else. <spec dir> sits where git reads options, because there is no -e. The code entries are pathspecs, not paths. And -l prints a name quoted unless it is plain ASCII.

Measured with plan over small sources, each a spec directory (.md files, so extension-majority puts it in the spec leg) and a code entry src/ holding src/reader.py, which names the spec directory. The follow-ups are what plan wrote:

control, spec dir `notes/`:        follow-ups (2): code/src/reader.py names `notes/`, which moves to the spec leg ...
spec dir `-notes/`:                follow-ups (1), the pull-request line only
                                   by hand: git grep -l -I -F '-notes/' HEAD -- src   exit 129, "error: unknown switch `t'" and git's usage
code dir `:cache/` holding the file that names `notes/`:
                                   follow-ups (1)
                                   by hand: git grep -l -I -F 'notes/' HEAD -- ':cache' src   exit 1, no output
                                   (git reads `:cache` as the pathspec `cache`, which is no code entry)
code dir `*/` (.py files), spec dir `notes/` whose own `notes/two.md` says "see notes/":
                                   follow-ups (3), the first naming `code/notes/two.md`, a file that moves to the SPEC leg
                                   by hand: git grep ... -- '*' src   HEAD:notes/two.md  HEAD:src/reader.py
code file `src/Übersicht.py` naming `notes/`:
                                   follow-up reads: code/"src/\303\234bersicht.py" names `notes/` ...   (git's quoted spelling, quotes and octal escapes included)
code dir `s?c/` beside a spec dir `sec/`:
                                   no change. `?` and `[..]` match a whole path, not a directory's contents, so only `*` widens.

A usage error is swallowed (proc.stdout is empty, so hits is empty), which is why the -notes/ row is silent: the plan is written, plan exits 0, and the follow-up the person needed is not there. The :cache/ row is silent because git searched the pathspec it read and found nothing.

It can run a command, narrowly. Python does not run one, but git can: -O<cmd> is git grep --open-files-in-pager, which git runs through a shell. A spec directory named -O<cmd> is read as that option, which makes the next argument, the 40-hex commit, the PATTERN, and the search becomes a search of the WORKTREE for that hash. When a tracked file under a code entry holds it, git runs <cmd> with the matching names. A clean checkout of the planned commit cannot hold its own hash, so an org/repo source cloned by gh is out of reach, and git skips an untracked file. A local --source <path> whose index holds such a file is not out of reach, and whoever prepared that directory decides what its index and worktree hold. Measured with a spec directory named -Otouch PWNED;/ and a file src/scratch.txt holding the planned commit's hash:

clean checkout of the planned commit:       plan exit 0, new files in the source directory: []
src/scratch.txt untracked, holding the hash: plan exit 0, new files in the source directory: []
src/scratch.txt in the index, holding it:    plan exit 0, new files in the source directory: ['PWNED']

So the usual consequence is prose, a wrong or missing follow-up line, and the severity is low; the one route to a command needs a prepared local source and a spec directory named -O.... I did not look for other routes. Whether to treat that as more than low is a decision for whoever picks this up.

What would fix it.

git --literal-pathspecs grep -z -l -I -F -e <spec dir> <commit> -- <code entries>

read by splitting on NUL (each record is <commit>:<path> with the path raw). -e makes the name a pattern and the commit a revision, --literal-pathspecs makes every entry a path (the way #196's branch runs git rm), and -z stops the quoting. Tried on a scratch copy of main with exactly that change, not committed: every row above returns the right file and only it. -notes/ and -Otouch/ are searched as patterns, :cache/a.py is found, * finds only src/reader.py, src/Übersicht.py is spelled as it is, and PWNED is not created. A test per row.

Not claimed.

Activity

  1. brettheap commented on Oct 11, 2026

    @brettheap
    ContributorAuthor

    CLAIMED — lane openRepoShape-3, session 566fec94-6fde-4579-947f-ec4fda5ce14f@Eagle, 2026-10-11T16:25:44Z, for #216

    Logged in lanes/log/openRepoShape-3.md at b6b2bbb5f4f10fbf4abf143c0824cf2868d3aaa1.

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

    1. existing `CLAIMED —` comments on opensoft/openRepoShape#216:
       none
    2. `gh pr list --repo opensoft/openRepoShape --state all --search "#216"`, kept where the row or its body names `#216`:
       none
    3. `git ls-remote --heads [email protected]:opensoft/openRepoShape` branches naming `216` as a whole token:
       none
    
  2. added 6 commits that reference this issue on Oct 12, 2026
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

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions