[PATCH] fixup! bash prompt: use bash builtins to find out current branch

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: SZEDER Gábor <szeder@xxxxxxxxxx>

---
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

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]