Skip to content

The agent that grows with you

fix(install): re-runs update tag-pinned narrow checkouts instead of aborting

kshitijk4poor44e42b2502bc
diff --git a/scripts/install.ps1 b/scripts/install.ps1
index 9328b266d23..079ad0f76e7 100644
--- a/scripts/install.ps1
+++ b/scripts/install.ps1
@@ -766,7 +766,9 @@ function Stage-Repository {
Invoke-Native { git -C $InstallDir remote set-url origin $RepoUrl }
if ($LASTEXITCODE) { Fail "cannot point origin at $RepoUrl" }
}
- Invoke-Logged "Fetching origin/$Branch" { git -C $InstallDir fetch origin $Branch }
+ # Explicit refspec: a tag-pinned --single-branch checkout from an older installer maps only
+ # the tag, so a by-name fetch never writes the origin/$Branch used below (#125112).
+ Invoke-Logged "Fetching origin/$Branch" { git -C $InstallDir fetch origin "+refs/heads/${Branch}:refs/remotes/origin/${Branch}" }
if ($LASTEXITCODE) { Fail "git fetch failed" }
$stamp = (Get-Date -Format 'yyyyMMdd-HHmmss')
# Park local work BEFORE switching branches: checkout refuses a dirty
@@ -786,7 +788,14 @@ function Stage-Repository {
if ($LASTEXITCODE) { Fail "could not stash local changes in $InstallDir; commit or move them aside, then rerun" }
Write-Warn "local changes stashed as hermes-install-autostash-$stamp"
}
- Invoke-Logged "Checking out $Branch" { git -C $InstallDir checkout $Branch }
+ # checkout's branch guess only sees remote refs the refspec maps, so a narrow checkout
+ # (detached at its tag, no local branch) gets the branch created at the fetched tip.
+ Invoke-Native { git -C $InstallDir show-ref --verify --quiet "refs/heads/$Branch" }
+ if ($LASTEXITCODE) {
+ Invoke-Logged "Checking out $Branch" { git -C $InstallDir checkout -b $Branch "origin/$Branch" }
+ } else {
+ Invoke-Logged "Checking out $Branch" { git -C $InstallDir checkout $Branch }
+ }
if ($LASTEXITCODE) { Fail "git checkout failed" }
# --no-stat: across a large gap (v2026.7.1 -> today is ~27k lines) the
# diffstat arrives as one burst. Hermes-Setup.exe forwards every line
diff --git a/scripts/install.sh b/scripts/install.sh
index 9d30fa77d40..335fe78ad75 100755
--- a/scripts/install.sh
+++ b/scripts/install.sh
@@ -480,7 +480,11 @@ stage_repository() {
if [ -n "${HERMES_REPO_URL:-}" ]; then
git -C "$INSTALL_DIR" remote set-url origin "$REPO_URL" || fail "cannot point origin at $REPO_URL"
fi
- run_logged "Fetching origin/$BRANCH" git -C "$INSTALL_DIR" fetch origin "$BRANCH" || fail "git fetch failed"
+ # Explicit refspec: a tag-pinned --single-branch checkout from an older
+ # installer maps only the tag, so a by-name fetch writes FETCH_HEAD and
+ # never the origin/$BRANCH everything below resolves (#125112).
+ run_logged "Fetching origin/$BRANCH" git -C "$INSTALL_DIR" fetch origin "+refs/heads/$BRANCH:refs/remotes/origin/$BRANCH" \
+ || fail "git fetch failed"
local stamp
stamp="$(date -u +%Y%m%d-%H%M%S)"
# Park local work BEFORE switching branches: checkout refuses a dirty
@@ -500,7 +504,15 @@ stage_repository() {
|| fail "could not stash local changes in $INSTALL_DIR; commit or move them aside, then rerun"
log_warn "local changes stashed as hermes-install-autostash-$stamp"
fi
- run_logged "Checking out $BRANCH" git -C "$INSTALL_DIR" checkout "$BRANCH" || fail "git checkout failed"
+ # checkout's branch guess only sees remote refs the refspec maps, so a
+ # narrow checkout (detached at its tag, no local branch) gets the branch
+ # created at the fetched tip.
+ if git -C "$INSTALL_DIR" show-ref --verify --quiet "refs/heads/$BRANCH"; then
+ run_logged "Checking out $BRANCH" git -C "$INSTALL_DIR" checkout "$BRANCH" || fail "git checkout failed"
+ else
+ run_logged "Checking out $BRANCH" git -C "$INSTALL_DIR" checkout -b "$BRANCH" "origin/$BRANCH" \
+ || fail "git checkout failed"
+ fi
if ! run_logged --may-fail "Fast-forwarding to origin/$BRANCH" \
git -C "$INSTALL_DIR" merge --ff-only "origin/$BRANCH"; then
# A release cut off the main line, a force-pushed remote, or the