]> git.pld-linux.org Git - packages/rpm-build-tools.git/blobdiff - bash-prompt.sh
don't override GETURI when using wget
[packages/rpm-build-tools.git] / bash-prompt.sh
index 467e4b372fac0e9dcb21da1860da98a595f7b749..5eec27643d2dc9ce6900c8fd2b289e975a7c8aec 100644 (file)
@@ -45,7 +45,7 @@ __bash_parse_git_branch() {
        # not in git dir. return early
        git rev-parse --git-dir &> /dev/null || return
 
-       local state remote branch
+       local state remote branch base local
 
        # without branch, nothing is shown; don't bother further
        branch=$(git symbolic-ref --short HEAD 2>/dev/null) || return
@@ -55,18 +55,22 @@ __bash_parse_git_branch() {
        fi
 
        # http://stackoverflow.com/a/3278427
-       local=$(git rev-parse @)
-       remote=$(git rev-parse '@{u}')
-       base=$(git merge-base @ '@{u}')
-
-       if [ $local = $remote ]; then
-               remote=""
-       elif [ $local = $base ]; then
-               remote="${YELLOW}↓"
-       elif [ $remote = $base ]; then
-               remote="${YELLOW}↑"
+       remote=$(git rev-parse '@{u}' 2>/dev/null)
+       base=$(git merge-base @ '@{u}' 2>/dev/null)
+       if [[ -n "$remote" && -n "$base" ]]; then
+               local=$(git rev-parse @)
+
+               if [[ $local = $remote ]]; then
+                       remote=""
+               elif [[ $local = $base ]]; then
+                       remote="${YELLOW}↓"
+               elif [[ $remote = $base ]]; then
+                       remote="${YELLOW}↑"
+               else
+                       remote="${YELLOW}↕"
+               fi
        else
-               remote="${YELLOW}↕"
+               remote=""
        fi
 
        echo " (${branch})${remote}${state}"
This page took 0.815439 seconds and 4 git commands to generate.