git-prompt: preserve value of $? in all cases

Signed-off-by: Tony Finch <dot@dotat.at> Reviewed-by: SZEDER Gábor <szeder@ira.uka.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Tony Finch committed Jan 14, 2015 at 10:06 UTC 6babe76496db332d589c1a2e0a2344fe41ca1dd5
1 file changed +4 -4
contrib/completion/git-prompt.sh
+4 -4
@@ -288,6 +288,7 @@ __git_eread ()
288 # In this mode you can request colored hints using GIT_PS1_SHOWCOLORHINTS=true
289 __git_ps1 ()
290 {
291 + # preserve exit status
292 local exit=$?
293 local pcmode=no
294 local detached=no
@@ -303,7 +304,7 @@ __git_ps1 ()
304 ;;
305 0|1) printf_format="${1:-$printf_format}"
306 ;;
306 - *) return
307 + *) return $exit
308 ;;
309 esac
310
@@ -355,7 +356,7 @@ __git_ps1 ()
356 #In PC mode PS1 always needs to be set
357 PS1="$ps1pc_start$ps1pc_end"
358 fi
358 - return
359 + return $exit
360 fi
361
362 local short_sha
@@ -416,7 +417,7 @@ __git_ps1 ()
417 if [ $pcmode = yes ]; then
418 PS1="$ps1pc_start$ps1pc_end"
419 fi
419 - return
420 + return $exit
421 fi
422 # is it a symbolic ref?
423 b="${head#ref: }"
@@ -513,6 +514,5 @@ __git_ps1 ()
514 printf -- "$printf_format" "$gitstring"
515 fi
516
516 - # preserve exit status
517 return $exit
518 }