Skip to content

Commit

Permalink
Add $GitPromptSettings.EnableFileStatus
Browse files Browse the repository at this point in the history
  • Loading branch information
dahlbyk committed Sep 16, 2010
1 parent ecce857 commit fb7c0df
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
5 changes: 3 additions & 2 deletions GitPrompt.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ $global:GitPromptSettings = New-Object PSObject -Property @{
AutoRefreshIndex = $true

EnablePromptStatus = $true
EnableFileStatus = $true
}

function Write-GitStatus($status) {
Expand All @@ -54,7 +55,7 @@ function Write-GitStatus($status) {
Write-Host $currentBranch -NoNewline -BackgroundColor $s.Branch2BackgroundColor -ForegroundColor $s.Branch2ForegroundColor
}

if($status.HasIndex) {
if($s.EnableFileStatus -and $status.HasIndex) {
write-host $s.BeforeIndexText -NoNewLine -BackgroundColor $s.BeforeIndexBackgroundColor -ForegroundColor $s.BeforeIndexForegroundColor

if($s.ShowStatusWhenZero -or $status.Index.Added) {
Expand All @@ -76,7 +77,7 @@ function Write-GitStatus($status) {
}
}

if($status.HasWorking) {
if($s.EnableFileStatus -and $status.HasWorking) {
if($s.ShowStatusWhenZero -or $status.Working.Added) {
Write-Host " +$($status.Working.Added.Count)" -NoNewline -BackgroundColor $s.WorkingBackgroundColor -ForegroundColor $s.WorkingForegroundColor
}
Expand Down
11 changes: 8 additions & 3 deletions GitUtils.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,12 @@ function Get-GitStatus($gitDir = (Get-GitDirectory)) {
$filesDeleted = @()
$filesUnmerged = @()

$status = git status --short --branch 2>$null
if($settings.EnableFileStatus) {
$status = git status --short --branch 2>$null
} else {
$status = @()
}

$status | where { $_ } | foreach {
switch -regex ($_) {
'^## (?<branch>\S+)(?:\.\.\.(?<upstream>\S+) \[(?:ahead (?<ahead>\d+))?(?:, )?(?:behind (?<behind>\d+))?\])?$' {
Expand Down Expand Up @@ -117,7 +122,7 @@ function Get-GitStatus($gitDir = (Get-GitDirectory)) {
Add-Member -PassThru NoteProperty Deleted $filesDeleted |
Add-Member -PassThru NoteProperty Unmerged $filesUnmerged

$status = New-Object PSObject -Property @{
$result = New-Object PSObject -Property @{
GitDir = $gitDir
Branch = $branch
AheadBy = $aheadBy
Expand All @@ -128,7 +133,7 @@ function Get-GitStatus($gitDir = (Get-GitDirectory)) {
HasUntracked = [bool]$filesAdded
}

return $status
return $result
}
}

Expand Down

0 comments on commit fb7c0df

Please sign in to comment.