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

[PATCH] Add bare repository indicator for __git_ps1

From
MSMarius Storm-Olsen <git@storm-olsen.com>
Date
Feb 21, 2009, 14:48 UTC
Message-ID
<1235227723-11471-1-git-send-email-git@storm-olsen.com>

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

Signed-off-by: Marius Storm-Olsen <git@storm-olsen.com>
---
 Ok, had some free cycles, so here's fixed up version.
 Based on next this time
 contrib/completion/git-completion.bash |   10 ++++++++--
 1 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index ec587d2..e585d40 100755
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -135,11 +135,17 @@ __git_ps1 ()
 			fi
 		fi
 
+		local c
+
+		if [ "true" = "$(git config --bool core.bare 2>/dev/null)" ]; then
+			c="BARE:"
+		fi
+
 		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.rc1.20.g8c5b
Next: Marius Storm-Olsen
Message 1 of 18 in “Add bare repository indicator for __git_ps1”
  1. Add bare repository indicator for __git_ps1Marius Storm-Olsen, Feb 21, 2009
  2. Marius Storm-OlsenFeb 21, 2009
  3. Junio C HamanoFeb 21, 2009
  4. Marius Storm-OlsenFeb 21, 2009
  5. Junio C HamanoFeb 22, 2009
  6. Marius Storm-OlsenFeb 23, 2009
  7. Shawn O. PearceFeb 23, 2009
  8. Marius Storm-OlsenFeb 23, 2009
  9. Shawn O. PearceFeb 23, 2009
  10. Marius Storm-OlsenFeb 23, 2009
  11. Junio C HamanoFeb 24, 2009
  12. Ted PavlicFeb 24, 2009
  13. Marius Storm-OlsenFeb 24, 2009
  14. Ted PavlicFeb 24, 2009
  15. Junio C HamanoFeb 24, 2009
  16. Marius Storm-OlsenFeb 24, 2009
  17. Junio C HamanoFeb 25, 2009
  18. Marius Storm-OlsenFeb 25, 2009

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.