Repository navigation
Description
Problem
scripts/hardware-doc-init.sh promises in its header (:17-21) that an existing sibling hardware-doc checkout is kept current safely — "Only ever fast-forwards. No merge, no rebase, no reset" — and carries a ~35-line update block implementing exactly that: detached-HEAD, dirty-tree, no-upstream, fetch-failure, up-to-date, fast-forward, unpushed-commits and diverged cases (:76-110). That block is unreachable dead code, so an existing checkout is never updated at all.
The reuse-or-clone chain at :59-110 is:
if [ -d "$TARGET/.git" ]; then
ok "using existing checkout at $TARGET" # :59-65 — adopt as-is, no update
...
elif [ ! -e "$TARGET" ]; then
... clone ... # :66-71
elif [ ! -d "$TARGET/.git" ]; then
err "$TARGET exists but is not a git repository" # :72-74
else
# --- update, but never destructively --- # :76-110 — DEAD
BRANCH="$(git -C "$TARGET" symbolic-ref ...)"
...
fiThe else requires all three earlier conditions to be false: ! -d "$TARGET/.git" (from branch 1), $TARGET exists (from branch 2), and -d "$TARGET/.git" (negation of branch 3) — a contradiction. Every existing checkout takes branch 1 and is adopted exactly as found, however stale.
Verified on laptop @ 0a5c705a23 (probe ~/git/fleet/probe-hwdoc, real script verbatim, md5 269dbe024f43bb51f79fb4e3bb439b3a): fixture code repo beside a hardware-doc clone that is clean, on main, upstream configured, and strictly behind by one commit. The script exits 0 printing ✓ using existing checkout at ... and the symlink is created — but the sibling HEAD is byte-identical before and after (06c29b5c1ef…), while upstream sits at 6c2e23ea906…. No fetch, no fast-forward, no warning that the checkout is behind. The dirty/detached/diverged safeguards in the dead block likewise never run, so a diverged checkout is adopted with the same green checkmark as a current one.
Why it matters
- The script is the documented entry point for bringing the hardware-doc knowledge base beside the repo; anyone re-running it to pick up new hardware research silently keeps whatever vintage they first cloned, while the output claims success.
- The dead block is the script's entire safety story for updates (never touch a dirty checkout, warn on divergence). Its unreachability means those warnings can never fire either — staleness and divergence are both invisible.
- The link-2 section comment (:195-205) tells future editors to "mirror the clone/update block used for hardware-doc above" — the block it points at does not execute, so the pattern propagates the defect.
Acceptance criteria
- Running the script with an existing clean, behind, upstream-tracking
hardware-doccheckout fast-forwards it and reports the fast-forward (the :99 message or equivalent). - The existing safeguards actually execute: detached HEAD, dirty tree, missing upstream, fetch failure, unpushed commits, and divergence each produce their warning and leave the checkout untouched.
- The not-a-repository case (
$TARGETexists without.git) still errors out, and the absent case still clones. - A regression test (fixture repos: behind / dirty / diverged / detached / no-upstream / not-a-repo / absent) covers the branch routing; the symlink behaviour of the current script is unchanged for the clone and adopt paths.
Activity
developing-today commentedon Nov 7, 2026
CODE-2152
dezren39 commentedon Nov 7, 2026
🤖 Agent note · filed
dezren39 commentedon Nov 8, 2026
🤖 Agent note · picked up
4 remaining items
developing-today commentedon Nov 8, 2026
🤖 Agent note · parked
Merge pull request #7035 from developing-today/queue/11287-6890-hardw…
developing-today commentedon Nov 8, 2026
🤖 Agent note · done