Add bare repository indicator for __git_ps1
authorMarius Storm-Olsen <git@storm-olsen.com>
Sat, 21 Feb 2009 14:48:43 +0000 (15:48 +0100)
committerJunio C Hamano <gitster@pobox.com>
Mon, 23 Feb 2009 23:23:39 +0000 (15:23 -0800)
Prefixes the branch name with "BARE:" if you're in a
bare repository.

Signed-off-by: Marius Storm-Olsen <git@storm-olsen.com>
Acked-by: Shawn O. Pearce <spearce@spearce.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
contrib/completion/git-completion.bash

index 6e8c5b9..a61d852 100755 (executable)
@@ -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