]> git.pld-linux.org Git - packages/rpm-build-tools.git/commitdiff
bash-prompt: skip comparing with remote if upstream not defined for branch
authorElan Ruusamäe <glen@delfi.ee>
Sun, 20 Nov 2016 18:10:37 +0000 (20:10 +0200)
committerElan Ruusamäe <glen@delfi.ee>
Sun, 20 Nov 2016 18:10:37 +0000 (20:10 +0200)
bash-prompt.sh

index 467e4b372fac0e9dcb21da1860da98a595f7b749..959fd028ac094cfed203045a09ef3d82638a3af1 100644 (file)
@@ -55,18 +55,20 @@ __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}↑"
-       else
-               remote="${YELLOW}↕"
+       remote=$(git rev-parse '@{u}' 2>/dev/null)
+       if [[ -n "$remote" ]]; then
+               local=$(git rev-parse @)
+               base=$(git merge-base @ '@{u}')
+
+               if [[ $local = $remote ]]; then
+                       remote=""
+               elif [[ $local = $base ]]; then
+                       remote="${YELLOW}↓"
+               elif [[ $remote = $base ]]; then
+                       remote="${YELLOW}↑"
+               else
+                       remote="${YELLOW}↕"
+               fi
        fi
 
        echo " (${branch})${remote}${state}"
This page took 0.072433 seconds and 4 git commands to generate.