From: SZEDER Gábor <>

When the environment variable $GIT_PS1_SHOWSTASHSTATE is set
__git_ps1() checks the presence of stashes by running 'git rev-parse
--verify refs/stash'.  This command not only checks that the
'refs/stash' ref exists but also, well, verifies that it's a valid

However, we don't need to be that thorough for the bash prompt.  We
can omit that verification and only check whether 'refs/stash' exists
or not.  Since 'git pack-refs' never packs 'refs/stash', it's a matter
of checking the existence of a ref file.  Perform this check using
only bash builtins to spare the overhead of fork()+exec()ing a git

Signed-off-by: SZEDER Gábor <>
 contrib/completion/ | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/contrib/completion/ b/contrib/completion/
index b73cebf7..208e2ec7 100644
--- a/contrib/completion/
+++ b/contrib/completion/
@@ -421,8 +421,9 @@ __git_ps1 ()
-               if [ -n "${GIT_PS1_SHOWSTASHSTATE-}" ]; then
-                       git rev-parse --verify refs/stash >/dev/null 2>&1 && 
+               if [ -n "${GIT_PS1_SHOWSTASHSTATE-}" ] &&
+                  [ -r "$g/refs/stash" ]; then
+                       s="$"
                if [ -n "${GIT_PS1_SHOWUNTRACKEDFILES-}" ] &&

To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to
More majordomo info at

Reply via email to