Re: [PATCH] git-prompt: fix expansion of branch colour codes
Joakim Petersen <joak-pet@online.no> writes:
Show 9 quoted lines
> Because of the wrapping of the branch name variable $b, the colour codes
> in the variable don't get applied, but are instead printed directly in
> the output. Move the wrapping of $b to before colour codes are inserted
> to correct this.
>
> Signed-off-by: Joakim Petersen <joak-pet@online.no>
> ---
> contrib/completion/git-prompt.sh | 12 ++++++------
> 1 file changed, 6 insertions(+), 6 deletions(-)
t9903 seems to fail with this, though...?
Show 34 quoted lines
> diff --git a/contrib/completion/git-prompt.sh b/contrib/completion/git-prompt.sh
> index cb01c2fd5d..1435548e00 100644
> --- a/contrib/completion/git-prompt.sh
> +++ b/contrib/completion/git-prompt.sh
> @@ -556,9 +556,14 @@ __git_ps1 ()
> fi
> fi
>
> - b=${b##refs/heads/}
> 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
> @@ -566,11 +571,6 @@ __git_ps1 ()
> fi
> fi
>
> - 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}"
>
>
> base-commit: 9470605a1b03dac8fc4f801132e36964b4fbb8c3