Skip to content

Commit 2be9291

Browse files
committed
bugfix: when one file was renamed, all others appeared as modified as well
1 parent d9ab07d commit 2be9291

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

Git-NumberedAdd/lib/Parse-GitStatus.ps1

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ function Parse-GitStatus($includeNumstat = $false, $extraArgs) {
3030
$allArgs = @('status', '-s')
3131
if ($extraArgs) { $allArgs += $extraArgs }
3232
$allFiles = Invoke-Git @allArgs | % {
33+
$oldFilename = $null
3334
$relativePath = $_.Substring(3).Replace("`"", "")
3435

3536
if ($relativePath -match " -> ") {

Tests/Parse-GitStatus.Tests.ps1

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,25 @@ Describe 'Parse-GitStatus' {
2424
$result[1].staged | Should -Be $false
2525
}
2626

27+
It 'Resets file rename for next file' {
28+
Mock Invoke-Git {
29+
"R TestDrive:\file0 -> TestDrive:\spacey file2"
30+
"M TestDrive:\file1"
31+
}
32+
$result = Parse-GitStatus
33+
34+
$result.Length | Should -Be 2
35+
$result[0].file | Should -Be "`"TestDrive:\spacey file2`""
36+
$result[0].state | Should -Be "R"
37+
$result[0].oldFile | Should -Be "TestDrive:\file0"
38+
$result[0].staged | Should -Be $true
39+
40+
$result[1].file | Should -Be "TestDrive:\file1"
41+
$result[1].state | Should -Be "M"
42+
$result[1].oldFile | Should -Be $null
43+
$result[1].staged | Should -Be $true
44+
}
45+
2746
It 'Add quotes around filename with spaces if it is not yet the case' {
2847
Mock Invoke-Git { "?? TestDrive:\spacey file2" }
2948
$result = Parse-GitStatus

0 commit comments

Comments
 (0)