Skip to content

adopt-project.py: _default_branch reads origin/HEAD and HEAD by short name, so a source cloned with git clone -b <branch> is refused git-failed with no remedy, and a HEAD on a local origin/x or on a name ending in U+00A0 adopts another branch's commit #797

Closed

Description

@brettheap

Goal: the default branch adopt-project.py reads is a branch the source has, read by its full ref name and its exact bytes. A source whose origin/HEAD names a branch with no local copy is refused with a remedy that works, and --tracking-branch does not depend on the default branch.

Filed by lane openRepoShape-1 from #457's lines L1-68, L1-69 and L1-71 (#457, comment) on Brett Heap's word of 2026-10-17T10:21:32Z, under lane 3's v1.1.1 rule (#473, issuecomment-6216697223). Each line was measured again on main bf1f099b with a stub gh.

Milestone: v1.1.1. L1-71's second case is reached by an ordinary git clone -b <branch>, or a deleted local main. It stops plan, check and execute with git's own words and no way out, and the obvious flag does not help. L1-68 and L1-69 are silent wrong commits, but need unusual branch names.

Lines

  • L1-71, case 2: origin/HEAD names a branch with no local copy.
    • After git clone -b dev <url>, origin/HEAD names origin/main and only dev is local. plan gives REFUSED git-failed: \git rev-parse main` … fatal: ambiguous argument 'main': unknown revision…`, exit 2, with no Remediation line.
    • plan --tracking-branch dev is refused the same way, because Source._at runs rev-parse on the default branch first.
    • check on a plan made before the local main went away gives the same refusal.
    • After git branch main origin/main, plan exits 0.
  • L1-68: a HEAD on main followed by U+00A0, beside a branch main. plan exits 0 and records default_branch: main and the commit of the OTHER branch. .strip() after decoding removes the U+00A0.
  • L1-69: a HEAD on a local branch named origin/x, beside a branch x. plan exits 0 and adopts x's commit, because origin/ is stripped from the HEAD read too.
  • L1-71, case 1 (rider): a source whose only branch is café. It is refused unsafe-value with only the pattern as its remedy. The way through works: git branch main, then --tracking-branch main, exits 0. The remedy should say so.
  • Also measured (not a Tracking: adopt-project.py, converting an existing repository in place #457 line), same function: a tag named main makes symbolic-ref --short HEAD print heads/main. plan then records tracking_branch: heads/main, and check says plan-tracking-branch-missing.

Direction

Tests: extend tests/test_adopt_branch_names.py, tests/test_adopt_tracking_branch.py and tests/test_adopt_git_reads.py.

Overlaps: #765 is the sibling for update-shape.py, family.py and bump-leg.py, and lane 1 holds it too. _default_branch reads with binary=True, so #710's decode rule does not reach it.

Lane: openreposhape-1 (openRepoShape-1)

🤖 Generated with Claude Code

Activity

  1. added this to the v1.1.1 milestone on Oct 17, 2026
  2. brettheap commented on Oct 17, 2026

    @brettheap
    ContributorAuthor

    CLAIMED — lane openRepoShape-1, session 300f8f46-004a-4e72-8587-4f192be2e108@Eagle, 2026-10-17T10:43:48Z, for #797

    Logged in lanes/log/openRepoShape-1.md at 388085d9734f00c568cf3365c7dac83aeba1f2c1.

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

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

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions