Summary
Follow-up to #1660 / #4151 (merged): the Gittensory Orb review on #4151 flagged two
non-blocking precision nits in the new scripts/selfhost-update.sh that are worth
fixing before they confuse an operator in the field.
Details
- The
git merge --ff-only failure path prints the same "local history has diverged"
message regardless of the actual cause. If SELFHOST_UPDATE_BRANCH/
SELFHOST_UPDATE_REMOTE is mistyped (or points at a branch the remote genuinely
doesn't have), git merge --ff-only <bad-ref> fails the same way as a real
divergence, and the operator gets told their history has diverged when the real
problem is a bad ref. Add a git rev-parse --verify check right after the fetch so
a missing ref gets its own distinct, actionable error.
current_branch="$(git rev-parse --abbrev-ref HEAD)" returns the literal string
HEAD in a detached-HEAD checkout, so the existing branch-mismatch error reads
"currently on 'HEAD', expected 'main'" and suggests a nonsensical
SELFHOST_UPDATE_BRANCH=HEAD override. Give detached HEAD its own message.
A related doc/test correction: test/unit/docs-selfhost-git-deploy-hygiene.test.ts's
comment on the tracked-file-shadowing test overstated the risk of a tracked file
matching the new .gitignore backup patterns (.gitignore does not untrack an
already-tracked file, verified empirically). Correct the comment to describe the real
risk: a new file matching the pattern would be silently excluded from git status
and git add -A, not that an existing tracked file would be dropped.
Acceptance criteria
scripts/selfhost-update.sh gives a distinct error for a missing/invalid
$REMOTE/$BRANCH ref, separate from the non-fast-forward-divergence error.
scripts/selfhost-update.sh gives a distinct error for a detached-HEAD checkout.
- The inaccurate
.gitignore semantics claim in the test comment is corrected.
- New test coverage for both new error paths.
Summary
Follow-up to #1660 / #4151 (merged): the Gittensory Orb review on #4151 flagged two
non-blocking precision nits in the new
scripts/selfhost-update.shthat are worthfixing before they confuse an operator in the field.
Details
git merge --ff-onlyfailure path prints the same "local history has diverged"message regardless of the actual cause. If
SELFHOST_UPDATE_BRANCH/SELFHOST_UPDATE_REMOTEis mistyped (or points at a branch the remote genuinelydoesn't have),
git merge --ff-only <bad-ref>fails the same way as a realdivergence, and the operator gets told their history has diverged when the real
problem is a bad ref. Add a
git rev-parse --verifycheck right after the fetch soa missing ref gets its own distinct, actionable error.
current_branch="$(git rev-parse --abbrev-ref HEAD)"returns the literal stringHEADin a detached-HEAD checkout, so the existing branch-mismatch error reads"currently on 'HEAD', expected 'main'" and suggests a nonsensical
SELFHOST_UPDATE_BRANCH=HEADoverride. Give detached HEAD its own message.A related doc/test correction:
test/unit/docs-selfhost-git-deploy-hygiene.test.ts'scomment on the tracked-file-shadowing test overstated the risk of a tracked file
matching the new
.gitignorebackup patterns (.gitignoredoes not untrack analready-tracked file, verified empirically). Correct the comment to describe the real
risk: a new file matching the pattern would be silently excluded from
git statusand
git add -A, not that an existing tracked file would be dropped.Acceptance criteria
scripts/selfhost-update.shgives a distinct error for a missing/invalid$REMOTE/$BRANCHref, separate from the non-fast-forward-divergence error.scripts/selfhost-update.shgives a distinct error for a detached-HEAD checkout..gitignoresemantics claim in the test comment is corrected.