Re: [PATCH] completion: Add space to PS1 when showing upstream
From: Junio C Hamano <hidden>
Date: 2016-06-15 22:50:48
Todd Zullinger [off-list ref] 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?
quoted hunk
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.