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