summaryrefslogtreecommitdiff
path: root/functions
diff options
context:
space:
mode:
authorBen Hilburn <bhilburn@gmail.com>2016-04-12 15:53:25 +0300
committerBen Hilburn <bhilburn@gmail.com>2016-04-12 15:53:25 +0300
commit3ee1f419c79aff3f63d78713a562731f871f9ddc (patch)
treeceb4b0b065d94001327d823fc30b7cee23d7882a /functions
parent154181ffc2830445c30eed74949e700ad2cd5a2a (diff)
parent14e213bd681d9e6733f753cb068fb491a4e174f0 (diff)
Merge branch 'next' of https://github.com/nmaggioni/powerlevel9k into nmaggioni-next
Diffstat (limited to 'functions')
-rw-r--r--functions/vcs.zsh21
1 files changed, 17 insertions, 4 deletions
diff --git a/functions/vcs.zsh b/functions/vcs.zsh
index 9d3883ca..074d1e05 100644
--- a/functions/vcs.zsh
+++ b/functions/vcs.zsh
@@ -61,10 +61,23 @@ function +vi-git-remotebranch() {
}
function +vi-git-tagname() {
- local tag
-
- tag=$(git describe --tags --exact-match HEAD 2>/dev/null)
- [[ -n "${tag}" ]] && hook_com[branch]="$(print_icon 'VCS_TAG_ICON')${tag}"
+ # Only show the tag name if we are not in DETACHED_HEAD state,
+ # or if the current branch's HEAD is the same commit as a tag but
+ # doesn't have the same name
+ local tag
+ tag=$(git describe --tags --exact-match HEAD 2>/dev/null)
+
+ if [[ -z "$(git symbolic-ref HEAD 2>/dev/null)" || ! -z "${tag}" ]] ; then
+ head=$(git describe --all)
+ # Make sure that detached head or checked out name differs from tag name
+ if [[ "${head}" != "${tag}" ||
+ "$(git rev-parse --abbrev-ref HEAD)" != "${tag}" &&
+ "$(git rev-parse --abbrev-ref HEAD)" != "HEAD" &&
+ "$(git rev-list -n 1 HEAD)" == "$(git rev-list -n 1 ${tag})" ]]; then
+ # Append the tag segment to the branch one
+ [[ -n "${tag}" ]] && hook_com[branch]+=" $(print_icon 'VCS_TAG_ICON')${tag}"
+ fi
+ fi
}
# Show count of stashed changes