Merge branch 'ks/rebase-i-abbrev'
[gitweb.git] / contrib / completion / git-prompt.sh
index 75c3f0f4eaa579403e6b2d376d8f4baebe3dd59c..214e859f99e7d896a6fa45a737b5b3e2a629176f 100644 (file)
@@ -293,6 +293,8 @@ __git_eread ()
 # In this mode you can request colored hints using GIT_PS1_SHOWCOLORHINTS=true
 __git_ps1 ()
 {
+       # preserve exit status
+       local exit=$?
        local pcmode=no
        local detached=no
        local ps1pc_start='\u@\h:\w '
@@ -311,7 +313,7 @@ __git_ps1 ()
                ;;
                0|1)    printf_format="${1:-$printf_format}"
                ;;
-               *)      return
+               *)      return $exit
                ;;
        esac
 
@@ -359,7 +361,7 @@ __git_ps1 ()
        rev_parse_exit_code="$?"
 
        if [ -z "$repo_info" ]; then
-               return
+               return $exit
        fi
 
        local short_sha
@@ -379,7 +381,7 @@ __git_ps1 ()
           [ "$(git config --bool bash.hideIfPwdIgnored)" != "false" ] &&
           git check-ignore -q .
        then
-               return
+               return $exit
        fi
 
        local r=""
@@ -425,7 +427,7 @@ __git_ps1 ()
                else
                        local head=""
                        if ! __git_eread "$g/HEAD" head; then
-                               return
+                               return $exit
                        fi
                        # is it a symbolic ref?
                        b="${head#ref: }"
@@ -521,4 +523,6 @@ __git_ps1 ()
        else
                printf -- "$printf_format" "$gitstring"
        fi
+
+       return $exit
 }