Skip to content

source-control: worktree-create.sh bare-repo root detection + git ref-syntax validation (PR #898 follow-ups) #1016

Description

@kyle-sexton

This was generated by AI during triage (#657 sweep housekeeping, T8h batch conversion).

Two valid P2 edge cases on plugins/source-control/scripts/worktree-create.sh, deferred as follow-ups from the 2026-07-22 PR #898 verifier-resolver lane review threads (codex P2, dispositioned + resolved under delegation — deferred as follow-ups, change-freeze on the branch at the time, no fix-repush that cycle). Folded from a #657 line (checked off there, this issue is the batch).

Site 1 — bare-repo roots (in-checkout guard)

A worktree_root under a bare clone (e.g. /repos/other.git/worktrees) makes git rev-parse --show-toplevel fail (no working tree), so the guard falls through and git worktree add creates a checkout inside the bare repo's git dir — violating the "root outside every repository" contract.

Fix direction: also detect a bare-repository ancestor (e.g. probe git rev-parse --is-bare-repository / --git-dir on the nearest existing ancestor) before creating.

Site 2 — git ref-syntax validation (name check)

Names like feat/foo..bar, feat/., foo.lock pass the char-class regex + 64-char limit but git rejects them as refs, so the helper reaches git worktree add and returns environment exit 4 despite documenting an up-front exit 2 for invalid names.

Fix direction: run git check-ref-format --branch after the schema check so the correction flow receives the intended usage error (exit 2).

Acceptance: a bare-repo-rooted worktree_root is rejected before git worktree add runs; an invalid ref-syntax name returns exit 2 (not exit 4). Both sites are mechanical validation-guard fixes; no open design fork.

Work-class: C3 (bug-fix-shaped) — attended triage 2026-07-23, operator-ratified. 🤖

Metadata

Metadata

Assignees

Labels

agent-readyFully specified and briefed; eligible for autonomous pickup from the frontier.priority: mediumReal value, no hard deadline; normal backlog flow.status: readyTriaged, unblocked, and fully specified; eligible to pick up.work-class: scopedA briefed fix or small feature; blast radius bounded by the brief, tests exist.

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions