From: Junio C Hamano Date: Wed, 26 Dec 2012 19:45:48 GMT Subject: Re: [PATCH] make __git_ps1 accept a third parameter in pcmode Message-ID: <7vmwx0oavn.fsf@alter.siamese.dyndns.org> In-Reply-To: <20121226191505.GA29210@simaj.xs4all.nl> Simon Oosthoek writes: > The optional third parameter when __git_ps1 is used in > PROMPT_COMMAND mode as format string for printf to further > customize the way the git status string is embedded in the > user's PS1 prompt. > > Signed-off-by: Simon Oosthoek > --- Thanks. If we do not care about the existing users (and in this case, because PROMPT_COMMAND mode is in no released version, we could declare there is no existing user), another and simpler approach is to just drop " (" and ")" altogether and have the user give these as part of the pre/post strings. Or we could go the other way and drop "pre/post" strings, making them part of the printf_format string. Perhaps that might be a better interface in the longer term. Then people can use the same "
%s" format string and do either of these:

	PS1=$(__git_ps1 "
%s")
	PROMPT_COMMAND='PS1=$(__git_ps1 "
%s")'

without __git_ps1 having a special "prompt command" mode, no?

I have a feeling that I am missing something major, though...

>  				if [ "$w" = "*" ]; then
> -					PS1="$PS1\[$bad_color\]$w"
> +					gitstring="$gitstring\[$bad_color\]$w"
>  				fi

Every time I looked at this line, I wondered why '*' state is
"bad".  Does a user go into any "bad" state by having a dirty
working tree?  Same for untracked ($u) and detached.  These are all
perfectly normal part of a workflow, so while choice of red may be
fine to attract attention, calling it "bad" sounds misguided.