Re: [PATCH] git-prompt: fix expansion of branch colour codes

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Joakim Petersen <joak-pet@xxxxxxxxx> writes:

> 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@xxxxxxxxx>
> ---
>  contrib/completion/git-prompt.sh | 12 ++++++------
>  1 file changed, 6 insertions(+), 6 deletions(-)

t9903 seems to fail with this, though...?

> 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



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux