{"thread":{"id":"26773","subject":"[PATCH] completion: Add space to PS1 when showing upstream","startedAt":"2011-03-18T15:02:22Z","lastAt":"2011-03-18T20:01:35Z","messageCount":2,"participants":["Todd Zullinger","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"163645","messageId":"20110318150222.GB26236@inocybe.localdomain","threadId":"26773","inReplyTo":null,"subject":"[PATCH] completion: Add space to PS1 when showing upstream","fromName":"Todd Zullinger","fromEmail":"tmz@pobox.com","sentAt":"2011-03-18T15:02:22Z","receivedAt":"2011-03-18T15:02:22Z","isPatch":true,"sender":{"key":"tmz@pobox.com","avatar":"https://avatars.githubusercontent.com/u/806319?v=4"},"body":"Depending on whether other changes were present or displayed in PS1, the\nprompt may have lacked a space between the branch and the upstream\nmarker.  Add this space as needed so the branch name and upstream state\naren't confusingly mixed.\n\nSigned-off-by: Todd Zullinger <tmz@pobox.com>\n---\n contrib/completion/git-completion.bash |    1 +\n 1 files changed, 1 insertions(+), 0 deletions(-)\n\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex 0b0b913..e5af5f6 100755\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -312,6 +312,7 @@ __git_ps1 ()\n \t\tfi\n \n \t\tlocal f=\"$w$i$s$u\"\n+\t\t[[ -z $f ]] && p=\"${p:+ $p}\"\n \t\tprintf \"${1:- (%s)}\" \"$c${b##refs/heads/}${f:+ $f}$r$p\"\n \tfi\n }\n-- \n1.7.4.1\n\n-- \nTodd        OpenPGP -> KeyID: 0xBEAF0CE3 | URL: www.pobox.com/~tmz/pgp\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\nGiving money and power to government is like giving whiskey and car\nkeys to teenage boys.\n    -- P.J. O'Rourke\n"},{"id":"163667","messageId":"7vtyf0w63k.fsf@alter.siamese.dyndns.org","threadId":"26773","inReplyTo":"20110318150222.GB26236@inocybe.localdomain","subject":"Re: [PATCH] completion: Add space to PS1 when showing upstream","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2011-03-18T20:01:35Z","receivedAt":"2011-03-18T20:01:35Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Todd Zullinger <tmz@pobox.com> writes:\n\n> Depending on whether other changes were present or displayed in PS1, the\n> prompt may have lacked a space between the branch and the upstream\n> marker.\n\nThe grossly misnamed __git_ps1_show_upstream that does not show anything\nbut only sets variable $p gives a non-alphanumeric mnemonic (e.g. p=\">\")\nthat is not ambiguous without an extra leading SP under non verbose mode\nto make things shorter, and in verbose mode the returned string comes its\nown leading SP, e.g. \" u+\" followed by number of commits.  So why would\nyou want an extra SP in front of that SP that already exists?\n\n> diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\n> index 0b0b913..e5af5f6 100755\n> --- a/contrib/completion/git-completion.bash\n> +++ b/contrib/completion/git-completion.bash\n> @@ -312,6 +312,7 @@ __git_ps1 ()\n>  \t\tlocal f=\"$w$i$s$u\"\n> +\t\t[[ -z $f ]] && p=\"${p:+ $p}\"\n>  \t\tprintf \"${1:- (%s)}\" \"$c${b##refs/heads/}${f:+ $f}$r$p\"\n\nBesides, you confused me with the description. You are checking $f to\ndecide if you add an extra SP in front of $p but what comes in the end\nresult is \"$f$r$p\", so \"between the branch and marker\" is not even true.\nAlso why is $r ignored while deciding if you need this extra SP in the\nfirst place?\n\nI also happen to think that the user should not even be worried about the\ndivergence with the upstream when the repository is in any of the special\nstates, in which case $r is not empty (e.g. \"|REBASE-i\").  So the above\npart may become:\n\n\tlocal f=\"$w$i$s$u\"\n\tprintf \"${1:- (%s)}\" \"$c${b##refs/heads/}${f:+ $f}${p:-$r}\"\n\nBut that would be a separate topic.\n"}]}