From: SZEDER Gábor Date: Tue, 18 Jun 2013 10:01:38 GMT Subject: [PATCH] fixup! bash prompt: use bash builtins to find out current branch Message-ID: <1371549698-16826-1-git-send-email-szeder@ira.uka.de> In-Reply-To: <20130618094931.GB2204@goldbirke> From: SZEDER Gábor --- On Tue, Jun 18, 2013 at 11:49:31AM +0200, SZEDER Gábor wrote: > (Hmm, speaking of which, the > patch reading HEAD might break setups using $PROMPT_COMMAND, because > it might do a simple return without updating $PS1...) Indeed. Here's the fixup. contrib/completion/git-prompt.sh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/contrib/completion/git-prompt.sh b/contrib/completion/git-prompt.sh index 4e5c8efa..3c8c7b0d 100644 --- a/contrib/completion/git-prompt.sh +++ b/contrib/completion/git-prompt.sh @@ -362,7 +362,12 @@ __git_ps1 () b="$(git symbolic-ref HEAD 2>/dev/null)" else local head="" - read head 2>/dev/null <"$g/HEAD" || return + if ! read head 2>/dev/null <"$g/HEAD"; then + if [ $pcmode = yes ]; then + PS1="$ps1pc_start$ps1pc_end" + fi + return + fi # is it a symbolic ref? b="${head#ref: }" if [ "$head" = "$b" ]; then -- 1.8.3.1.487.g8f4672d