fix(install): re-clone interrupted (commit-less) checkout instead of failing
An interrupted previous clone leaves the install dir's .git present but with no initial commit. rev-parse --is-inside-work-tree and git status both still succeed there, so the installer entered the update path and ran `git stash`, which aborts with "You do not have the initial commit yet" and failed the desktop install at the "Cloning Hermes repository" stage. - install.ps1: add a `git rev-parse --verify HEAD` probe to the repo-validity check so a commit-less checkout is treated as broken and re-cloned fresh. - install.sh: mirror it at the top of clone_repo() — drop a partial checkout with no resolvable HEAD so the fresh-clone path handles it (POSIX parity). Fixes #40998
This commit is contained in:
+15
-4
@@ -1060,9 +1060,10 @@ function Install-Repository {
|
||||
# directory OR a symlink OR a submodule-style gitfile -- and also when
|
||||
# it's a broken stub left over from a failed previous install (e.g.
|
||||
# a partial Remove-Item that couldn't delete a locked index.lock).
|
||||
# Validate the repo properly by asking git itself. Two checks
|
||||
# belt-and-braces: rev-parse AND git status. If either fails the
|
||||
# repo is broken and we fall through to a fresh clone.
|
||||
# Validate the repo properly by asking git itself. Three checks
|
||||
# belt-and-braces: rev-parse (work tree), git status, and a resolvable
|
||||
# HEAD (an initial commit). If any fails the repo is broken and we
|
||||
# fall through to a fresh clone.
|
||||
$repoValid = $false
|
||||
if (Test-Path "$InstallDir\.git") {
|
||||
Push-Location $InstallDir
|
||||
@@ -1077,7 +1078,17 @@ function Install-Repository {
|
||||
$null = & git -c windows.appendAtomically=false status --short 2>&1
|
||||
$statusOk = ($LASTEXITCODE -eq 0)
|
||||
|
||||
if ($revParseOk -and $statusOk) {
|
||||
# An interrupted previous clone leaves a repo with NO initial
|
||||
# commit. rev-parse/status still succeed there, but the update
|
||||
# path's `git stash` (and later `git checkout`) abort with
|
||||
# "You do not have the initial commit yet" and fail the install
|
||||
# (#40998). Require a resolvable HEAD so such partial checkouts
|
||||
# are treated as broken and re-cloned fresh below.
|
||||
$global:LASTEXITCODE = 0
|
||||
$null = & git -c windows.appendAtomically=false rev-parse --verify HEAD 2>&1
|
||||
$hasCommit = ($LASTEXITCODE -eq 0)
|
||||
|
||||
if ($revParseOk -and $statusOk -and $hasCommit) {
|
||||
$repoValid = $true
|
||||
}
|
||||
} catch {}
|
||||
|
||||
Reference in New Issue
Block a user