git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
Todd Zullinger <tmz@pobox.com>
Date
Mar 18, 2011, 15:02 UTC
Message-ID
<20110318150222.GB26236@inocybe.localdomain>

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. Add this space as needed so the branch name and upstream state aren't confusingly mixed.

Signed-off-by: Todd Zullinger <tmz@pobox.com>
---
 contrib/completion/git-completion.bash |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
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 ()
 		fi
 
 		local f="$w$i$s$u"
+		[[ -z $f ]] && p="${p:+ $p}"
 		printf "${1:- (%s)}" "$c${b##refs/heads/}${f:+ $f}$r$p"
 	fi
 }
-- 
1.7.4.1

-- 
Todd        OpenPGP -> KeyID: 0xBEAF0CE3 | URL: www.pobox.com/~tmz/pgp
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Giving money and power to government is like giving whiskey and car
keys to teenage boys.
    -- P.J. O'Rourke
Next: Junio C Hamano
Message 1 of 2 in “completion: Add space to PS1 when showing upstream”
  1. completion: Add space to PS1 when showing upstreamTodd Zullinger, Mar 18, 2011
  2. Junio C HamanoMar 18, 2011

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.