fix: harden local installation guide
This commit is contained in:
@@ -64,8 +64,17 @@ The safest recovery is to reclone into a new directory. First commit wanted work
|
||||
backup outside both clones. Then clone with conversion disabled, run the verifier, and copy back
|
||||
only reviewed changes.
|
||||
|
||||
If a reviewed working tree must be repaired in place, make a backup or commit all wanted changes
|
||||
before continuing. Then use Git's repository attributes to stage a renormalization:
|
||||
If a reviewed working tree must be repaired in place, Git must first normalize the index, export
|
||||
that exact index to a separate repair directory, verify the exported bytes, and only then copy the
|
||||
verified tracked files over the worktree. `git add --renormalize .` alone does not change existing
|
||||
worktree bytes.
|
||||
|
||||
> **WARNING — destructive worktree rewrite.** Make a backup outside the clone or commit every
|
||||
> wanted tracked change before continuing. The copy step below overwrites tracked worktree bytes
|
||||
> from the staged index export. Stop if the staged diff does not contain exactly the wanted content;
|
||||
> untracked files are neither exported nor repaired.
|
||||
|
||||
From WSL2, Git Bash, macOS, or Linux:
|
||||
|
||||
```sh
|
||||
git status --short
|
||||
@@ -73,8 +82,48 @@ git config --local core.autocrlf false
|
||||
git add --renormalize .
|
||||
git diff --cached --check
|
||||
git diff --cached
|
||||
REPAIR_DIR="$(cd .. && pwd -P)/ThothII-lf-repair"
|
||||
if [[ -e "$REPAIR_DIR" ]]; then
|
||||
echo "Choose a new empty LF repair directory: $REPAIR_DIR" >&2
|
||||
exit 1
|
||||
fi
|
||||
mkdir -p "$REPAIR_DIR"
|
||||
REPAIR_PREFIX="$REPAIR_DIR/"
|
||||
git checkout-index --all --force --prefix="$REPAIR_PREFIX"
|
||||
bash scripts/verify-line-endings.sh "$REPAIR_DIR"
|
||||
# WARNING: destructive copy; make a backup or commit wanted changes before this command.
|
||||
git ls-files -z | while IFS= read -r -d '' path; do
|
||||
cp "$REPAIR_DIR/$path" "$path"
|
||||
done
|
||||
bash scripts/verify-line-endings.sh
|
||||
```
|
||||
|
||||
Review every staged change before committing. The procedure intentionally avoids destructive Git
|
||||
resets; replacing the clone is easier to audit and much safer for uncommitted work.
|
||||
Native Windows PowerShell runs the same Git operations and invokes the byte verifier through Git
|
||||
for Windows:
|
||||
|
||||
```powershell
|
||||
git status --short
|
||||
git config --local core.autocrlf false
|
||||
git add --renormalize .
|
||||
git diff --cached --check
|
||||
git diff --cached
|
||||
$RepairDir = Join-Path (Split-Path -Parent (Get-Location).Path) 'ThothII-lf-repair'
|
||||
if (Test-Path $RepairDir) { throw 'Choose a new empty LF repair directory.' }
|
||||
New-Item -ItemType Directory -Path $RepairDir | Out-Null
|
||||
$RepairPrefix = $RepairDir.Replace('\', '/') + '/'
|
||||
git checkout-index --all --force --prefix=$RepairPrefix
|
||||
& "C:\Program Files\Git\bin\bash.exe" scripts/verify-line-endings.sh $RepairDir
|
||||
if ($LASTEXITCODE -ne 0) { throw 'The staged index export does not satisfy the LF policy.' }
|
||||
# WARNING: destructive copy; make a backup or commit wanted changes before this command.
|
||||
git ls-files | ForEach-Object {
|
||||
Copy-Item -LiteralPath (Join-Path $RepairDir $_) -Destination $_ -Force
|
||||
}
|
||||
& "C:\Program Files\Git\bin\bash.exe" scripts/verify-line-endings.sh
|
||||
if ($LASTEXITCODE -ne 0) { throw 'Tracked worktree bytes were not repaired to the LF policy.' }
|
||||
```
|
||||
|
||||
The first verifier proves the exported index bytes before any overwrite; the final verifier
|
||||
examines the repaired worktree bytes and must also exit `0`. Review the staged diff again before
|
||||
committing, then remove the separate repair directory only after inspecting it. The procedure
|
||||
intentionally avoids `git reset --hard`; replacing the clone is easier to audit and much safer for
|
||||
uncommitted work.
|
||||
|
||||
Reference in New Issue
Block a user