From 36ec589a6ba796544ac6cbd9b84ca7e28deea788 Mon Sep 17 00:00:00 2001 From: Brett Heap Date: Sat, 24 Oct 2026 14:23:02 +0000 Subject: [PATCH] shape_materialize.py: the docstring of `gives_a_branch_another_name` says a full name that is no pattern takes the one ref git completes it to, which may be a branch, where it said any other source names no branch (#1238) The docstring ended "ANY OTHER SOURCE NAMES NO BRANCH, though a refspec from one can still put a ref on a branch's name". That is true of a source in another namespace, such as `refs/pull/7/head`, and untrue of a full name that is no pattern, which git completes: the source `refs/h` is the exact ref, the branch `refs/heads/refs/h`, the tag `refs/tags/refs/h`, `refs/refs/h` or `refs/remotes/refs/h`. Where the remote has a branch of that name the source is a branch, and beside a branch `hy` the carried refspec `+refs/h:refs/remotes/origin/hy` exits 128 ("Cannot fetch both refs/heads/hy and refs/heads/refs/h to refs/remotes/origin/hy"). The same source onto `origin/refs/h`, the branch's own name, or onto a name no branch has, exits 0 (measured on git 2.43.0 and 2.47.1, local bare remotes: rv1235's probes, run again here with the same answers). The sentence now says that any other source takes no branch by a pattern; that a full name that is no pattern takes the one ref git completes it to on the remote, `refs/h` itself or one such as the branch `refs/heads/refs/h` or the tag `refs/tags/refs/h`; that such a name can stand for a branch its spelling does not show, so it is not left out here; and that a refspec from any such source can still put a ref on a branch's name if the ref is not that branch itself, the clash `origin_fetch_refspecs` describes (WHAT CAN STILL CLASH). Wording only, in one docstring. `gives_a_branch_another_name("refs/h", ...)` is False and the refspec is carried, as on main. The file's syntax tree with every docstring dropped is as on main (`ast.dump`). The two sentences that say "whose source names no branch" (`shape_materialize.py` WHAT CAN STILL CLASH, `bump-leg.py` `_leg_fetch_refspecs`) are left: they define the clashing shape by its examples, the pull requests, and make no claim about what git completes a name to. Closes #1238 Lane: openreposhape-5 (openRepoShape-5) Co-Authored-By: Claude Sonnet 5.5 --- scripts/shape_materialize.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/scripts/shape_materialize.py b/scripts/shape_materialize.py index c4bac256..6526fac1 100644 --- a/scripts/shape_materialize.py +++ b/scripts/shape_materialize.py @@ -1718,9 +1718,15 @@ def gives_a_branch_another_name(source: str, destination: str) -> bool: `refs/heads-archive/old` for `refs/heads*`, and `origin_fetch_refspecs` says what leaving those out costs (BUT A COMMIT ONLY A REF THAT IS NO BRANCH REACHES). A shorter start, such as `refs/*` or `*`, can name a - tag, and that clause has left it out first. ANY OTHER SOURCE NAMES NO - BRANCH, though a refspec from one can still put a ref on a branch's - name: `origin_fetch_refspecs` says where (WHAT CAN STILL CLASH). + tag, and that clause has left it out first. ANY OTHER SOURCE TAKES NO + BRANCH BY A PATTERN, and a full name that is no pattern, such as + `refs/h`, takes the one ref git completes it to on the remote: that ref + itself, or one such as the branch `refs/heads/refs/h` or the tag + `refs/tags/refs/h` (measured, git 2.43 and 2.47.1). Such a name can + stand for a branch its spelling does not show, so it is not left out + here. A refspec from any such source can still put a ref on a branch's + name, if the ref is not that branch itself: `origin_fetch_refspecs` + says where (WHAT CAN STILL CLASH). """ fixed, star, _ = source.partition("*") if not source.startswith(HEADS_PREFIX):