Test.ps1
Push-Location 'C:\Users\fhertell\Source\git\Layer2\GitTest' $files = New-Object hashtable git diff step1 step2 | % { switch -Regex ($_) { '^diff --git a([^\s]+).*$' { $currentPatch = $null $patches = New-Object System.Collections.ArrayList $files.Add($Matches[1], $patches) | Out-Null break; } '^@@[^@]+@@$' { $currentPatch = [[PSCustomObject]@ { Lines = (New-Object System.Collections.ArrayList); }] $patches.Add($currentPatch) | Out-Null $inpatch = $true break; } '\\ No newline at end of file' { break; } Default { if ($inpatch) { $currentPatch.Add($_) | Out-Null } break; } } } Pop-Location return $files |