From 5eb0f37867b68ff6d5060a4ef823a5a444fdcc52 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Wed, 31 Aug 2016 17:38:35 +1200 Subject: Restore git symbolic-ref as first attempt Otherwise if two branches point to the same commit, you can't be sure which one will show up. --- bash/bashrc.d/prompt.bash | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'bash/bashrc.d') diff --git a/bash/bashrc.d/prompt.bash b/bash/bashrc.d/prompt.bash index b95cf92a..55c33282 100644 --- a/bash/bashrc.d/prompt.bash +++ b/bash/bashrc.d/prompt.bash @@ -108,8 +108,10 @@ prompt() { # failing all of that just show the short commit ID, in that order # of preference; if none of that works, bail out local name - name=$(git describe --all --always --exact-match \ - HEAD 2>/dev/null) || return + name=$( { + git symbolic-ref --quiet HEAD || + git describe --all --always --exact-match HEAD + } 2>/dev/null) || return name=${name##*/} [[ -n $name ]] || return -- cgit v1.2.3