git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Marius Storm-Olsen <git@storm-olsen.com>
To: spearce@spearce.org
Cc: git@vger.kernel.org, Marius Storm-Olsen <git@storm-olsen.com>
Subject: [PATCH v3] Add bare repository indicator for __git_ps1
Date: Sat, 21 Feb 2009 20:20:57 +0100	[thread overview]
Message-ID: <1235244057-16912-1-git-send-email-git@storm-olsen.com> (raw)

Prefixes the branch name with "BARE:" if you're in a
bare repository.

Signed-off-by: Marius Storm-Olsen <git@storm-olsen.com>
---
 Well there you go. That's what you get for not testing your
 patch after a rebase.. another version. ;-)

 Next had progressed into handling the --inside-git-dir case,
 and would replace branch name with "GIT_DIR!". Now, that's
 not so useful when that GIT_DIR! is a bare repository, so
 this version will prefix the branch name with "BARE:"
 instead.

 contrib/completion/git-completion.bash |   11 ++++++++---
 1 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index ec587d2..90ba428 100755
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -117,9 +117,14 @@ __git_ps1 ()
 
 		local w
 		local i
+		local c
 
 		if [ "true" = "$(git rev-parse --is-inside-git-dir 2>/dev/null)" ]; then
-			b="GIT_DIR!"
+			if [ "true" = "$(git config --bool core.bare 2>/dev/null)" ]; then
+				c="BARE:"
+			else
+				b="GIT_DIR!"
+			fi
 		elif [ "true" = "$(git rev-parse --is-inside-work-tree 2>/dev/null)" ]; then
 			if [ -n "${GIT_PS1_SHOWDIRTYSTATE-}" ]; then
 				if [ "$(git config --bool bash.showDirtyState)" != "false" ]; then
@@ -137,9 +142,9 @@ __git_ps1 ()
 
 		if [ -n "$b" ]; then
 			if [ -n "${1-}" ]; then
-				printf "$1" "${b##refs/heads/}$w$i$r"
+				printf "$1" "$c${b##refs/heads/}$w$i$r"
 			else
-				printf " (%s)" "${b##refs/heads/}$w$i$r"
+				printf " (%s)" "$c${b##refs/heads/}$w$i$r"
 			fi
 		fi
 	fi
-- 
1.6.2.rc0.5.gf970

                 reply	other threads:[~2009-02-21 19:24 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1235244057-16912-1-git-send-email-git@storm-olsen.com \
    --to=git@storm-olsen.com \
    --cc=git@vger.kernel.org \
    --cc=spearce@spearce.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).