Skip to content

Commit 6babe76

Browse files
fanf2gitster
authored andcommitted
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>
1 parent eb443e3 commit 6babe76

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

contrib/completion/git-prompt.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,7 @@ __git_eread ()
288288
# In this mode you can request colored hints using GIT_PS1_SHOWCOLORHINTS=true
289289
__git_ps1 ()
290290
{
291+
# preserve exit status
291292
local exit=$?
292293
local pcmode=no
293294
local detached=no
@@ -303,7 +304,7 @@ __git_ps1 ()
303304
;;
304305
0|1) printf_format="${1:-$printf_format}"
305306
;;
306-
*) return
307+
*) return $exit
307308
;;
308309
esac
309310

@@ -355,7 +356,7 @@ __git_ps1 ()
355356
#In PC mode PS1 always needs to be set
356357
PS1="$ps1pc_start$ps1pc_end"
357358
fi
358-
return
359+
return $exit
359360
fi
360361

361362
local short_sha
@@ -416,7 +417,7 @@ __git_ps1 ()
416417
if [ $pcmode = yes ]; then
417418
PS1="$ps1pc_start$ps1pc_end"
418419
fi
419-
return
420+
return $exit
420421
fi
421422
# is it a symbolic ref?
422423
b="${head#ref: }"
@@ -513,6 +514,5 @@ __git_ps1 ()
513514
printf -- "$printf_format" "$gitstring"
514515
fi
515516

516-
# preserve exit status
517517
return $exit
518518
}

0 commit comments

Comments
 (0)