]> rtime.felk.cvut.cz Git - git.git/commitdiff
Merge branch 'tf/prompt-preserve-exit-status'
authorJunio C Hamano <gitster@pobox.com>
Wed, 14 Jan 2015 20:35:48 +0000 (12:35 -0800)
committerJunio C Hamano <gitster@pobox.com>
Wed, 14 Jan 2015 20:35:49 +0000 (12:35 -0800)
Using the exit status of the last command in the prompt, e.g.
PS1='$(__git_ps1) $? ', did not work well because the helper
function stomped on the exit status.

* tf/prompt-preserve-exit-status:
  git-prompt: preserve value of $? in all cases

1  2 
contrib/completion/git-prompt.sh

index c0f62b54d4e7702234b97f0da14e3194a65985f2,3a11f4e97d7a3329bf0e5c37c603f8768cd2acd2..214e859f99e7d896a6fa45a737b5b3e2a629176f
@@@ -360,7 -352,11 +361,7 @@@ __git_ps1 (
        rev_parse_exit_code="$?"
  
        if [ -z "$repo_info" ]; then
-               return
 -              if [ $pcmode = yes ]; then
 -                      #In PC mode PS1 always needs to be set
 -                      PS1="$ps1pc_start$ps1pc_end"
 -              fi
+               return $exit
        fi
  
        local short_sha
        local inside_gitdir="${repo_info##*$'\n'}"
        local g="${repo_info%$'\n'*}"
  
-               return
 +      if [ "true" = "$inside_worktree" ] &&
 +         [ -n "${GIT_PS1_HIDE_IF_PWD_IGNORED-}" ] &&
 +         [ "$(git config --bool bash.hideIfPwdIgnored)" != "false" ] &&
 +         git check-ignore -q .
 +      then
++              return $exit
 +      fi
 +
        local r=""
        local b=""
        local step=""
                else
                        local head=""
                        if ! __git_eread "$g/HEAD" head; then
-                               return
 -                              if [ $pcmode = yes ]; then
 -                                      PS1="$ps1pc_start$ps1pc_end"
 -                              fi
+                               return $exit
                        fi
                        # is it a symbolic ref?
                        b="${head#ref: }"