Skip to content

Commit

Permalink
Removed error thrown by symbolic-ref and describe
Browse files Browse the repository at this point in the history
git describe can be replaced by tag --points-at <commitish>. Other than symbolic-ref, describe does not have a --quiet switch, thus always adds to $error in case of a detached head with no tag pointing to that commit. Using tag --point-at HEAD will return a tag if one is found but not throw an error when there is none.
  • Loading branch information
JanDeDobbeleer committed Oct 10, 2016
1 parent c39da78 commit cbd6be9
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions GitUtils.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,15 @@ function Get-GitBranch($gitDir = $(Get-GitDirectory), [Diagnostics.Stopwatch]$sw
}

$b = Invoke-NullCoalescing `
{ dbg 'Trying symbolic-ref' $sw; git symbolic-ref HEAD 2>$null } `
{ dbg 'Trying symbolic-ref' $sw; git symbolic-ref HEAD -q 2>$null } `
{ '({0})' -f (Invoke-NullCoalescing `
{
dbg 'Trying describe' $sw
switch ($Global:GitPromptSettings.DescribeStyle) {
'contains' { git describe --contains HEAD 2>$null }
'branch' { git describe --contains --all HEAD 2>$null }
'describe' { git describe HEAD 2>$null }
default { git describe --tags --exact-match HEAD 2>$null }
default { git tag --points-at HEAD 2>$null }
}
} `
{
Expand Down

0 comments on commit cbd6be9

Please # to comment.