Re: [PATCH] completion: Add space to PS1 when showing upstream

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

 



Todd Zullinger <tmz@xxxxxxxxx> writes:

> Depending on whether other changes were present or displayed in PS1, the
> prompt may have lacked a space between the branch and the upstream
> marker.

The grossly misnamed __git_ps1_show_upstream that does not show anything
but only sets variable $p gives a non-alphanumeric mnemonic (e.g. p=">")
that is not ambiguous without an extra leading SP under non verbose mode
to make things shorter, and in verbose mode the returned string comes its
own leading SP, e.g. " u+" followed by number of commits.  So why would
you want an extra SP in front of that SP that already exists?

> diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
> index 0b0b913..e5af5f6 100755
> --- a/contrib/completion/git-completion.bash
> +++ b/contrib/completion/git-completion.bash
> @@ -312,6 +312,7 @@ __git_ps1 ()
>  		local f="$w$i$s$u"
> +		[[ -z $f ]] && p="${p:+ $p}"
>  		printf "${1:- (%s)}" "$c${b##refs/heads/}${f:+ $f}$r$p"

Besides, you confused me with the description. You are checking $f to
decide if you add an extra SP in front of $p but what comes in the end
result is "$f$r$p", so "between the branch and marker" is not even true.
Also why is $r ignored while deciding if you need this extra SP in the
first place?

I also happen to think that the user should not even be worried about the
divergence with the upstream when the repository is in any of the special
states, in which case $r is not empty (e.g. "|REBASE-i").  So the above
part may become:

	local f="$w$i$s$u"
	printf "${1:- (%s)}" "$c${b##refs/heads/}${f:+ $f}${p:-$r}"

But that would be a separate topic.
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[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]