From 17eb15a214645ccf2bdb55967ea286bec31af8a2 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Mon, 23 Sep 2013 10:40:52 +1200 Subject: Clarify git branch/commit detection --- bash/bashrc.d/prompt.bash | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'bash/bashrc.d/prompt.bash') diff --git a/bash/bashrc.d/prompt.bash b/bash/bashrc.d/prompt.bash index 3f658fa2..e28b2dda 100644 --- a/bash/bashrc.d/prompt.bash +++ b/bash/bashrc.d/prompt.bash @@ -63,9 +63,13 @@ prompt() { # Attempt to determine git branch, bail if we can't local branch - branch=$(git symbolic-ref --quiet HEAD 2>/dev/null) \ - || branch=$(git rev-parse --short HEAD 2>/dev/null) \ - || return 1 + branch=$( { + git symbolic-ref --quiet HEAD \ + || git rev-parse --short HEAD + } 2>/dev/null ); + if ! [[ $branch ]]; then + return 1 + fi branch=${branch##*/} # Safely read status with -z --porcelain -- cgit v1.2.3