diff options
author | Tom Ryder <tom@sanctum.geek.nz> | 2016-08-31 17:38:35 +1200 |
---|---|---|
committer | Tom Ryder <tom@sanctum.geek.nz> | 2016-08-31 17:50:37 +1200 |
commit | 5eb0f37867b68ff6d5060a4ef823a5a444fdcc52 (patch) | |
tree | 825320cd58fb8ad959002a95dafdfc42123d5206 | |
parent | Add very basic Yash support (diff) | |
download | dotfiles-5eb0f37867b68ff6d5060a4ef823a5a444fdcc52.tar.gz dotfiles-5eb0f37867b68ff6d5060a4ef823a5a444fdcc52.zip |
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.
-rw-r--r-- | bash/bashrc.d/prompt.bash | 6 | ||||
-rw-r--r-- | pdksh/pdkshrc.d/prompt.pdksh | 6 |
2 files changed, 8 insertions, 4 deletions
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 diff --git a/pdksh/pdkshrc.d/prompt.pdksh b/pdksh/pdkshrc.d/prompt.pdksh index bac505a4..920e21ae 100644 --- a/pdksh/pdkshrc.d/prompt.pdksh +++ b/pdksh/pdkshrc.d/prompt.pdksh @@ -99,8 +99,10 @@ prompt() { # failing all of that just show the short commit ID, in that order # of preference; if none of that works, bail out typeset 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 |