From dd0b72cbd9e64c782a31c6acfca2ba9cf2ffb266 Mon Sep 17 00:00:00 2001 From: SZEDER Gábor Date: Fri, 1 Apr 2011 17:47:37 +0200 Subject: bash prompt: use bash builtins to check stash state MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 ref. 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 process. Also run 'git pack-refs --all' in the corresponding test to document that the prompt script depends on 'git pack-refs' not packing 'refs/stash' and to catch possible breakages should this behavior ever change. Signed-off-by: SZEDER Gábor --- t/t9903-bash-prompt.sh | 1 + 1 file changed, 1 insertion(+) (limited to 't/t9903-bash-prompt.sh') diff --git a/t/t9903-bash-prompt.sh b/t/t9903-bash-prompt.sh index b9895c797c..c05458cbe6 100755 --- a/t/t9903-bash-prompt.sh +++ b/t/t9903-bash-prompt.sh @@ -328,6 +328,7 @@ test_expect_success 'prompt - stash status indicator - stash' ' echo 2 >file && git stash && test_when_finished "git stash drop" && + git pack-refs --all && ( GIT_PS1_SHOWSTASHSTATE=y && __git_ps1 >"$actual" -- cgit v1.2.3