Permalink
Browse files

Fix errors with Set-PSDebug -Strict

Set-PSDebug -Strict will complain if any variable is used before it is
initialized. This was happening with the $sw variable.

The practical
effect of this bug was that the nice posh-git prompt would disappear if
"Set-PSDebug -Strict" was ever called in a PowerShell session.
  • Loading branch information...
1 parent fd36b16 commit c4ac7bff8ddb96480778f3cf2eb8b7a5218c4a35 @aroben aroben committed May 3, 2012
Showing with 5 additions and 1 deletion.
  1. +5 −1 GitUtils.ps1
View
@@ -82,7 +82,11 @@ function Get-GitStatus($gitDir = (Get-GitDirectory)) {
$enabled = (-not $settings) -or $settings.EnablePromptStatus
if ($enabled -and $gitDir)
{
- if($settings.Debug) { $sw = [Diagnostics.Stopwatch]::StartNew(); Write-Host '' }
+ if($settings.Debug) {
+ $sw = [Diagnostics.Stopwatch]::StartNew(); Write-Host ''
+ } else {
+ $sw = $null
+ }
$branch = $null
$aheadBy = 0
$behindBy = 0

0 comments on commit c4ac7bf

Please sign in to comment.