Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2c64ad41aa | ||
|
|
f13f143001 |
@@ -192,9 +192,11 @@ foreach ($e in $series) {
|
||||
if ($usePatchList -and $e.Name -notin $Patches) { continue }
|
||||
$file = Join-Path $patchesDir $e.Name
|
||||
if (-not (Test-Path -LiteralPath $file)) { throw "Patch missing: $file" }
|
||||
# Files the patch touches ("--- a/x" / "+++ b/x"), to scope the diff checks.
|
||||
# Files the patch touches ("--- a/x" / "+++ b/x", and each "diff --git a/x b/y" header, which a
|
||||
# binary patch has alone), to scope the diff checks.
|
||||
$paths = @(Get-Content -LiteralPath $file | ForEach-Object {
|
||||
if ($_ -match '^(?:---|\+\+\+) [ab]/(.+?)\s*$') { $Matches[1] }
|
||||
elseif ($_ -match '^diff --git a/(.+?) b/(.+?)\s*$') { $Matches[1]; $Matches[2] }
|
||||
} | Select-Object -Unique)
|
||||
$patchSpecs += @{
|
||||
Name = $e.Name
|
||||
@@ -226,7 +228,12 @@ foreach ($targetName in $byTarget.Keys) {
|
||||
# object count between the upstream clone and the single-commit verify repo.
|
||||
$diffArgs = @('-C', $repo, '-c', 'core.autocrlf=false', 'diff', '--full-index')
|
||||
if ($paths.Count) { $diffArgs += '--'; $diffArgs += $paths }
|
||||
$treeDiff = (& git @diffArgs | Out-String).Replace("`r`n", "`n").TrimEnd()
|
||||
# The mode on an "index" line is the file's, not the change's: the verify tree is extracted by
|
||||
# tar on Windows, which keeps no executable bit, so a changed executable (a prebuilt kext) reads
|
||||
# 100644 there and 100755 here. A change of mode has its own "old mode"/"new mode" lines, which
|
||||
# stay compared.
|
||||
$indexMode = '(?m)^(index [0-9a-f]+\.\.[0-9a-f]+) [0-7]{6}$'
|
||||
$treeDiff = ((& git @diffArgs | Out-String).Replace("`r`n", "`n") -replace $indexMode, '$1').TrimEnd()
|
||||
|
||||
# Apply the declared patch stack to a clean temporary clone of HEAD and compare diffs byte-for-byte.
|
||||
$verifyDir = Join-Path $TempRoot ("patch-verify-" + [guid]::NewGuid())
|
||||
@@ -270,7 +277,7 @@ foreach ($targetName in $byTarget.Keys) {
|
||||
Invoke-GitApply $verifyDir $patchText
|
||||
Remove-Item -LiteralPath $patchLf -Force
|
||||
}
|
||||
$expectedDiff = (& git -C $verifyDir -c core.autocrlf=false diff --full-index | Out-String).Replace("`r`n", "`n").TrimEnd()
|
||||
$expectedDiff = ((& git -C $verifyDir -c core.autocrlf=false diff --full-index | Out-String).Replace("`r`n", "`n") -replace $indexMode, '$1').TrimEnd()
|
||||
if ($treeDiff -ne $expectedDiff) {
|
||||
$treeStat = (& git -C $repo diff --stat -- @paths | Out-String).Trim()
|
||||
$expStat = (& git -C $verifyDir diff --stat | Out-String).Trim()
|
||||
|
||||
Reference in new issue
Block a user