Blame SOURCES/0007-git-prompt.patch

fdd391
From 7e546ae76da784185ba9515ed86e435ba17fdd65 Mon Sep 17 00:00:00 2001
fdd391
From: Petr Stodulka <pstodulk@redhat.com>
fdd391
Date: Wed, 29 Mar 2017 13:08:28 +0200
fdd391
Subject: [PATCH] git-prompt.sh: don't put unsanitized branch names in $PS1
fdd391
fdd391
---
fdd391
 contrib/completion/git-prompt.sh | 9 ++++++---
fdd391
 1 file changed, 6 insertions(+), 3 deletions(-)
fdd391
fdd391
diff --git a/contrib/completion/git-prompt.sh b/contrib/completion/git-prompt.sh
fdd391
index eaf5c36..2c872e5 100644
fdd391
--- a/contrib/completion/git-prompt.sh
fdd391
+++ b/contrib/completion/git-prompt.sh
fdd391
@@ -360,8 +360,11 @@ __git_ps1 ()
fdd391
 		fi
fdd391
 
fdd391
 		local f="$w$i$s$u"
fdd391
+		b=${b##refs/heads/}
fdd391
 		if [ $pcmode = yes ]; then
fdd391
 			local gitstring=
fdd391
+			__git_ps1_branch_name=$b
fdd391
+			b="\${__git_ps1_branch_name}"
fdd391
 			if [ -n "${GIT_PS1_SHOWCOLORHINTS-}" ]; then
fdd391
 				local c_red='\e[31m'
fdd391
 				local c_green='\e[32m'
fdd391
@@ -371,7 +374,7 @@ __git_ps1 ()
fdd391
 				local ok_color=$c_green
fdd391
 				local branch_color="$c_clear"
fdd391
 				local flags_color="$c_lblue"
fdd391
-				local branchstring="$c${b##refs/heads/}"
fdd391
+				local branchstring="$c$b"
fdd391
 
fdd391
 				if [ $detached = no ]; then
fdd391
 					branch_color="$ok_color"
fdd391
@@ -400,13 +403,13 @@ __git_ps1 ()
fdd391
 				fi
fdd391
 				gitstring="$gitstring\[$c_clear\]$r$p"
fdd391
 			else
fdd391
-				gitstring="$c${b##refs/heads/}${f:+ $f}$r$p"
fdd391
+				gitstring="$c$b${f:+ $f}$r$p"
fdd391
 			fi
fdd391
 			gitstring=$(printf -- "$printf_format" "$gitstring")
fdd391
 			PS1="$ps1pc_start$gitstring$ps1pc_end"
fdd391
 		else
fdd391
 			# NO color option unless in PROMPT_COMMAND mode
fdd391
-			printf -- "$printf_format" "$c${b##refs/heads/}${f:+ $f}$r$p"
fdd391
+			printf -- "$printf_format" "$c$b${f:+ $f}$r$p"
fdd391
 		fi
fdd391
 	fi
fdd391
 }
fdd391
-- 
fdd391
2.5.5
fdd391