From fff05011c08034ac9b6b68601b97397f6ed4c1c6 Mon Sep 17 00:00:00 2001 From: Roy Golan Date: Mon, 22 Jun 2015 14:13:59 +0300 Subject: [PATCH] Simplify branch name extraction Use symbolic-ref --short to get the branch name without the refs/heads Signed-off-by: Roy Golan --- gitstatus.sh | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/gitstatus.sh b/gitstatus.sh index 68d1a08..d167e90 100755 --- a/gitstatus.sh +++ b/gitstatus.sh @@ -19,13 +19,10 @@ if [ -z "${__GIT_PROMPT_DIR}" ]; then __GIT_PROMPT_DIR="$( cd -P "$( dirname "${SOURCE}" )" && pwd )" fi -gitsym=`git symbolic-ref HEAD` +branch=`git symbolic-ref HEAD --short` # if "fatal: Not a git repo .., then exit -case "$gitsym" in fatal*) exit 0 ;; esac - -# the current branch is the tail end of the symbolic reference -branch="${gitsym##refs/heads/}" # get the basename after "refs/heads/" +case "$branch" in fatal*) exit 0 ;; esac gitstatus=`git diff --name-status 2>&1`