Junio C Hamano <gits...@pobox.com> writes:

> Simon Oosthoek <s.oosth...@xs4all.nl> writes:
>
>> Hi
>>
>> Fixed the mistakes of the last one, and I'm now using the symbolic names 
>> "ok_color" and "bad_color".
>> The test for headless state is now more direct, and I hope it is still 
>> correct.
>>
>> /Simon
>
> Will apply with a bit more readable log message.
>
> I think it would be a good idea to squash something like the
> attached into this patch, though.

The reason for this suggestion is not to avoid running symbolic-ref
twice (which is a good side effect, though).  When you are in the
middle of bisection or multi-commit cherry-pick, for example, you
would conceptually be working on the original branch, but the HEAD
pointer may be detached.  Earlier parts of the existing code in the
function makes this distinction, and the same distinction should be
carried over to the new code that decides the color to paint things
in.

>  contrib/completion/git-prompt.sh | 7 +++----
>  1 file changed, 3 insertions(+), 4 deletions(-)
>
> diff --git i/contrib/completion/git-prompt.sh 
> w/contrib/completion/git-prompt.sh
> index dced628..9f0b6bb 100644
> --- i/contrib/completion/git-prompt.sh
> +++ w/contrib/completion/git-prompt.sh
> @@ -215,7 +215,7 @@ __git_ps1_show_upstream ()
>  __git_ps1 ()
>  {
>       local pcmode=no
> -     #defaults/examples:
> +     local detached=no
>       local ps1pc_start='\u@\h:\w '
>       local ps1pc_end='\$ '
>       local printf_format=' (%s)'
> @@ -264,7 +264,7 @@ __git_ps1 ()
>                       fi
>  
>                       b="$(git symbolic-ref HEAD 2>/dev/null)" || {
> -
> +                             detached=yes
>                               b="$(
>                               case "${GIT_PS1_DESCRIBE_STYLE-}" in
>                               (contains)
> @@ -335,8 +335,7 @@ __git_ps1 ()
>                               local flags_color="$c_lblue"
>                               local branchstring="$c${b##refs/heads/}"
>  
> -                             if git symbolic-ref HEAD 2>/dev/null 1>&2
> -                             then
> +                             if [ $detached = yes ]; then
>                                       branch_color="$ok_color"
>                               else
>                                       branch_color="$bad_color"
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to