From cbd6be9aaeceb985003c7ede992d0acd06f8a2c5 Mon Sep 17 00:00:00 2001 From: Jan De Dobbeleer Date: Mon, 10 Oct 2016 08:32:59 +0200 Subject: [PATCH] Removed error thrown by symbolic-ref and describe git describe can be replaced by tag --points-at . 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. --- GitUtils.ps1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/GitUtils.ps1 b/GitUtils.ps1 index 67f9c7112..29f0778ee 100644 --- a/GitUtils.ps1 +++ b/GitUtils.ps1 @@ -46,7 +46,7 @@ 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 @@ -54,7 +54,7 @@ function Get-GitBranch($gitDir = $(Get-GitDirectory), [Diagnostics.Stopwatch]$sw '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 } } } ` {