Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2022-06-21 20:07:50 +0300
committerJunio C Hamano <gitster@pobox.com>2022-06-21 20:07:50 +0300
commitddbc07872e86265dc30aefa5f4d881f762120044 (patch)
tree5267bc19fa672c5a8b0e3eab86c6aecf388b637f /contrib
parent325240dfd76bc6a47e5a89beccf27b236b70e2ac (diff)
parent0e5d9ef395467619b621540a7fdefbfc8062f2ac (diff)
Merge branch 'jp/prompt-clear-before-upstream-mark'
Bash command line prompt (in contrib/) update. * jp/prompt-clear-before-upstream-mark: git-prompt: fix expansion of branch colour codes git-prompt: make colourization consistent
Diffstat (limited to 'contrib')
-rw-r--r--contrib/completion/git-prompt.sh32
1 files changed, 17 insertions, 15 deletions
diff --git a/contrib/completion/git-prompt.sh b/contrib/completion/git-prompt.sh
index 87b2b916c0..1435548e00 100644
--- a/contrib/completion/git-prompt.sh
+++ b/contrib/completion/git-prompt.sh
@@ -245,7 +245,8 @@ __git_ps1_show_upstream ()
# Helper function that is meant to be called from __git_ps1. It
# injects color codes into the appropriate gitstring variables used
-# to build a gitstring.
+# to build a gitstring. Colored variables are responsible for clearing
+# their own color.
__git_ps1_colorize_gitstring ()
{
if [[ -n ${ZSH_VERSION-} ]]; then
@@ -271,22 +272,23 @@ __git_ps1_colorize_gitstring ()
else
branch_color="$bad_color"
fi
- c="$branch_color$c"
+ if [ -n "$c" ]; then
+ c="$branch_color$c$c_clear"
+ fi
+ b="$branch_color$b$c_clear"
- z="$c_clear$z"
- if [ "$w" = "*" ]; then
- w="$bad_color$w"
+ if [ -n "$w" ]; then
+ w="$bad_color$w$c_clear"
fi
if [ -n "$i" ]; then
- i="$ok_color$i"
+ i="$ok_color$i$c_clear"
fi
if [ -n "$s" ]; then
- s="$flags_color$s"
+ s="$flags_color$s$c_clear"
fi
if [ -n "$u" ]; then
- u="$bad_color$u"
+ u="$bad_color$u$c_clear"
fi
- r="$c_clear$r"
}
# Helper function to read the first line of a file into a variable.
@@ -556,6 +558,12 @@ __git_ps1 ()
local z="${GIT_PS1_STATESEPARATOR-" "}"
+ b=${b##refs/heads/}
+ if [ $pcmode = yes ] && [ $ps1_expanded = yes ]; then
+ __git_ps1_branch_name=$b
+ b="\${__git_ps1_branch_name}"
+ fi
+
# NO color option unless in PROMPT_COMMAND mode or it's Zsh
if [ -n "${GIT_PS1_SHOWCOLORHINTS-}" ]; then
if [ $pcmode = yes ] || [ -n "${ZSH_VERSION-}" ]; then
@@ -563,12 +571,6 @@ __git_ps1 ()
fi
fi
- b=${b##refs/heads/}
- if [ $pcmode = yes ] && [ $ps1_expanded = yes ]; then
- __git_ps1_branch_name=$b
- b="\${__git_ps1_branch_name}"
- fi
-
local f="$h$w$i$s$u$p"
local gitstring="$c$b${f:+$z$f}${sparse}$r${upstream}"