Merge branch 'tf/prompt-preserve-exit-status'
authorJunio C Hamano <gitster@pobox.com>
Wed, 7 Jan 2015 21:09:35 +0000 (13:09 -0800)
committerJunio C Hamano <gitster@pobox.com>
Wed, 7 Jan 2015 21:09:35 +0000 (13:09 -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 $? inside shell prompt

1  2 
contrib/completion/git-prompt.sh
index 729f7694795d1116ccedfc653f82da757e6e4ef4,5fe69d046f96161a1c360a49480cd118642e98f3..3c3fc6d5d94c5dc6a9ec291fc217b590a11c5be3
@@@ -270,7 -270,7 +270,7 @@@ __git_ps1_colorize_gitstring (
  
  __git_eread ()
  {
 -      f="$1"
 +      local f="$1"
        shift
        test -r "$f" && read "$@" <"$f"
  }
  # In this mode you can request colored hints using GIT_PS1_SHOWCOLORHINTS=true
  __git_ps1 ()
  {
+       local exit=$?
        local pcmode=no
        local detached=no
        local ps1pc_start='\u@\h:\w '
        else
                printf -- "$printf_format" "$gitstring"
        fi
+       # preserve exit status
+       return $exit
  }