diff --git a/src/GitUtils.ps1 b/src/GitUtils.ps1 index efe041075..3dbc7a14a 100644 --- a/src/GitUtils.ps1 +++ b/src/GitUtils.ps1 @@ -65,41 +65,51 @@ function Get-GitBranch($gitDir = $(Get-GitDirectory), [Diagnostics.Stopwatch]$sw Invoke-Utf8ConsoleCommand { dbg 'Finding branch' $sw $r = ''; $b = ''; $c = '' - if (Test-Path $gitDir\rebase-merge\interactive) { - dbg 'Found rebase-merge\interactive' $sw - $r = '|REBASE-i' - $b = "$(Get-Content $gitDir\rebase-merge\head-name)" - } - elseif (Test-Path $gitDir\rebase-merge) { + $step = ''; $total = '' + if (Test-Path $gitDir/rebase-merge) { dbg 'Found rebase-merge' $sw - $r = '|REBASE-m' - $b = "$(Get-Content $gitDir\rebase-merge\head-name)" + if (Test-Path $gitDir/rebase-merge/interactive) { + dbg 'Found rebase-merge/interactive' $sw + $r = '|REBASE-i' + } + else { + $r = '|REBASE-m' + } + $b = "$(Get-Content $gitDir/rebase-merge/head-name)" + $step = "$(Get-Content $gitDir/rebase-merge/msgnum)" + $total = "$(Get-Content $gitDir/rebase-merge/end)" } else { - if (Test-Path $gitDir\rebase-apply) { + if (Test-Path $gitDir/rebase-apply) { dbg 'Found rebase-apply' $sw - if (Test-Path $gitDir\rebase-apply\rebasing) { - dbg 'Found rebase-apply\rebasing' $sw + $step = "$(Get-Content $gitDir/rebase-merge/next)" + $total = "$(Get-Content $gitDir/rebase-merge/last)" + + if (Test-Path $gitDir/rebase-apply/rebasing) { + dbg 'Found rebase-apply/rebasing' $sw $r = '|REBASE' } - elseif (Test-Path $gitDir\rebase-apply\applying) { - dbg 'Found rebase-apply\applying' $sw + elseif (Test-Path $gitDir/rebase-apply/applying) { + dbg 'Found rebase-apply/applying' $sw $r = '|AM' } else { - dbg 'Found rebase-apply' $sw $r = '|AM/REBASE' } } - elseif (Test-Path $gitDir\MERGE_HEAD) { + elseif (Test-Path $gitDir/MERGE_HEAD) { dbg 'Found MERGE_HEAD' $sw $r = '|MERGING' } - elseif (Test-Path $gitDir\CHERRY_PICK_HEAD) { + elseif (Test-Path $gitDir/CHERRY_PICK_HEAD) { dbg 'Found CHERRY_PICK_HEAD' $sw $r = '|CHERRY-PICKING' } - elseif (Test-Path $gitDir\BISECT_LOG) { + elseif (Test-Path $gitDir/REVERT_HEAD) { + dbg 'Found REVERT_HEAD' $sw + $r = '|REVERTING' + } + elseif (Test-Path $gitDir/BISECT_LOG) { dbg 'Found BISECT_LOG' $sw $r = '|BISECTING' } @@ -120,9 +130,9 @@ function Get-GitBranch($gitDir = $(Get-GitDirectory), [Diagnostics.Stopwatch]$sw dbg 'Falling back on parsing HEAD' $sw $ref = $null - if (Test-Path $gitDir\HEAD) { - dbg 'Reading from .git\HEAD' $sw - $ref = Get-Content $gitDir\HEAD 2>$null + if (Test-Path $gitDir/HEAD) { + dbg 'Reading from .git/HEAD' $sw + $ref = Get-Content $gitDir/HEAD 2>$null } else { dbg 'Trying rev-parse' $sw @@ -153,6 +163,10 @@ function Get-GitBranch($gitDir = $(Get-GitDirectory), [Diagnostics.Stopwatch]$sw } } + if ($step -and $total) { + $r += " $step/$total" + } + "$c$($b -replace 'refs/heads/','')$r" } }