Skip to content

tests/test_family_bump_fetch_refspecs.py: a comment and a docstring say a refs/h source takes no branch, but git completes it to a branch or tag of that name, and beside a branch hy the fetch exits 128 Cannot fetch both (#1157 follow-up) #1230

Closed

Description

@brettheap

(lane openRepoShape-5, 2026-10-23)

Goal: the two passages of tests/test_family_bump_fetch_refspecs.py that say what the carried refspec +refs/h:refs/remotes/origin/hy takes say what git does with it, so a reader of the carried rule is not told that the source refs/h is never a branch.

Problem

#1157 (#1100) landed as 0d76e4c59. Its re-check found that the wording the last round added is not quite true (lane 5's re-check, rc1157b, NIT 1; #1157 issuecomment-6371455922, at the PR's head 368b87e9b). It is a wording NIT: the row and the code are right. Two passages say that a source refs/h, a start of refs/heads/ with no *, takes a ref "that is no branch". On main 50ce8ab15 the file's blob (6e752bbca9c9) is the PR head's, so the lines are the same:

580: #: `carried` where none does (`carried-refs-h-not-a-pattern`, a start of
581: #: `refs/heads/` with no `*`, is no pattern: it takes the one ref of that
582: #: name, which is no branch), and `skipped` for a negative refspec, which

and, in the docstring of test_which_clause_leaves_each_refspec_out (the claim is on :690-691):

689:     `refs/headsx/`, which no branch is under, `refs/h` with no `*`, a start
690:     of `refs/heads/` that is no pattern and takes only the ref of that name,
691:     which is no branch and may stand beside the branches (the re-check of
692:     #1157, NIT 1), and a branch, a folder of them or a pattern of them,
693:     each under the name `BRANCHES` gives it."""

The claim is true of an exact refs/h, which is no branch. It leaves out that git also completes a source: refs/h names a branch called refs/h (refs/heads/refs/h) and a tag called refs/h (refs/tags/refs/h) as well. With a branch literally named refs/h beside hy, the tools' fetch line exits 128 with Cannot fetch both refs/heads/hy and refs/heads/refs/h to refs/remotes/origin/hy: the source is a branch there, so "no branch" is not true of it. The clash is the one the code's own docstrings list as WHAT CAN STILL CLASH (scripts/shape_materialize.py:1874-1885 at main) and as the second way a carried refspec fails (scripts/bump-leg.py:1161-1175): a carried refspec onto a name that is a branch's. Main carries the refspec the same way, so nothing is new in #1157. What the two passages get wrong is only the words "no branch".

It does not change the row. carried is still the rule for +refs/h:refs/remotes/origin/hy, and the row carried-refs-h-not-a-pattern (line 649, in WHICH_CLAUSE) still kills mutant F2, which drops the bool(star) and from the clause's return (return bool(star) and HEADS_PREFIX.startswith(fixed), scripts/shape_materialize.py:1727 at main). The commit message of 0d76e4c59 and #1157's body carry the same sentence and cannot be changed, so these two passages are the only place to correct it.

Measured

  • The re-check, rc1157b, at 368b87e9b, git 2.43.0 and 2.47.1. The remote had branches main, hy and refs/h, so the ref refs/heads/refs/h and no ref refs/h. The tools' fetch line was the branches' glob plus +refs/h:refs/remotes/origin/hy. The result was fatal: Cannot fetch both refs/heads/hy and refs/heads/refs/h to refs/remotes/origin/hy, exit 128. The row's own answer is unchanged: the review ran -k carried-refs-h-not-a-pattern over both files on the head (2 passed, 123 deselected) and with F2 applied (2 failed).

  • Re-run by the drafter at main 50ce8ab15, git 2.43.0 only, with GIT_CONFIG_GLOBAL=/dev/null GIT_CONFIG_NOSYSTEM=1 and a bare remote on disk, no network. One remote per row, each given main and hy from one empty commit, then the row's ref, then, in a fresh mount with that remote as origin:

    git -C mount fetch origin '+refs/heads/*:refs/remotes/origin/*' '+refs/h:refs/remotes/origin/hy'
    
    The remote also has Result of the fetch
    the branch refs/h (refs/heads/refs/h, by push) fatal: Cannot fetch both refs/heads/hy and refs/heads/refs/h to refs/remotes/origin/hy, exit 128 (the review's message)
    the tag refs/h (refs/tags/refs/h, by push) fatal: Cannot fetch both refs/heads/hy and refs/tags/refs/h to refs/remotes/origin/hy, exit 128
    the exact ref refs/h, made by update-ref on the remote's disk fatal: Cannot fetch both refs/heads/hy and refs/h to refs/remotes/origin/hy, exit 128
    none of these fatal: couldn't find remote ref refs/h, exit 128 (the other documented way a carried refspec fails, bump-leg.py:1161-1164; not this clash)

    In the first three rows the clash is with the branch hy, because origin/hy is the destination, so what differs is what the message calls the source. The tag row and the exact-ref row are the drafter's, not the review's, and they show that the review's suggested wording, "or the branch git completes that name to", is narrower than git is: a tag is completed too.

  • A push of the exact ref is refused. The same bare remote refused git push ../remote.git main:refs/h with remote: error: refusing to update funny ref 'refs/h' remotely and [remote rejected] main -> refs/h (funny refname). So on a remote that pushes made, the "one ref of that name" the passages picture cannot exist; what such a remote can hold under that name is a branch or a tag.

Suggested fix

Wording only, in the two passages; no row and no script. The review's own words are "say 'takes the ref of that name, or the branch git completes that name to', or leave it". With the tag row the second half can say "the branch or tag", for example:

The wording is the owner's. The file wraps at 79 columns (its longest line is 79) and holds no non-ASCII line; the re-flowed lines must too. Whether the docstrings of scripts/shape_materialize.py (:1874, "a refspec carried whose source names no branch") and bump-leg.py (:1165) want the same word is the owner's call: they describe the shape by its examples (pull requests in a folder, a single name) and make no claim about refs/h; I did not find a false sentence in them.

Verify

  • The diff touches only comment lines and that one docstring of tests/test_family_bump_fetch_refspecs.py: the file's syntax tree, with the docstring of test_which_clause_leaves_each_refspec_out removed from both sides, equals main's (python3 -I, ast.dump; comments are not in the tree).
  • -k carried-refs-h-not-a-pattern over tests/test_family_bump_fetch_refspecs.py and tests/test_bump_leg_fetch_refspecs.py gives 2 passed, as at 368b87e9b (2 passed, 123 deselected); the two files' other ids are as before.
  • tests/test_repo_hygiene.py and tests/test_path_guard_hygiene.py pass; no added line is over 79 columns or holds a non-ASCII character.
  • git grep -n 'which is no branch' -- tests/test_family_bump_fetch_refspecs.py finds no sentence that says the source refs/h takes no branch.

Found by lane 5's re-check of #1157 (#1100), rc1157b, NIT 1 (#1157 issuecomment-6371455922), at 368b87e9b; re-read on main 50ce8ab15, where the quoted lines and their numbers are the file's, and re-run by the drafter (git 2.43.0) for the branch, tag, exact-ref and funny-ref rows.

Lane: openreposhape-5 (openRepoShape-5)

Activity

  1. brettheap commented on Oct 23, 2026

    @brettheap
    ContributorAuthor

    CLAIMED — lane openRepoShape-5, session 50cede29-ab82-4ca3-9f67-d98e1a58c8d2@Eagle, 2026-10-23T21:21:52Z, for #1230

    Logged in lanes/log/openRepoShape-5.md at e1aed0fd77e29c994411d5f059595e824aa856e0.

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

    1. existing `CLAIMED —` comments on opensoft/openRepoShape#1230:
       none
    2. `gh pr list --repo opensoft/openRepoShape --state all --search "#1230"`, kept where the row or its body names `#1230`:
       none
    3. `git ls-remote --heads [email protected]:opensoft/openRepoShape` branches naming `1230` 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

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions