Blame SOURCES/0007-git-prompt.patch

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