]> git.alrj.org Git - zsh.d.git/commitdiff
Git prompt: Fix missing subdirectory
authorAmand Tihon <amand.tihon@iba-group.com>
Mon, 24 Jan 2011 09:36:04 +0000 (10:36 +0100)
committerAmand Tihon <amand.tihon@iba-group.com>
Mon, 24 Jan 2011 09:36:04 +0000 (10:36 +0100)
When under .git, the prompt now shows the correct path to current
directory.

S60_git

diff --git a/S60_git b/S60_git
index 54e61d477ad110bc101814a157c7fdf88db7c995..7a9ba7a1d0fbd4f060530a8f2ab119fdcc3ea202 100644 (file)
--- a/S60_git
+++ b/S60_git
@@ -95,10 +95,15 @@ git_parse() {
 
     git_dir=$(git rev-parse --git-dir 2> /dev/null) || return
 
-    base_dir=${$(readlink -f "$git_dir/..")/$HOME/'~'}
+    if [[ "$(git rev-parse --is-bare-repository)" == "true" ]]; then
+      base_dir=${$(readlink -f "$git_dir")/$HOME/'~'}
+      sub_dir=${$(pwd)#$(readlink -f "$git_dir")}
+    else
+      base_dir=${$(readlink -f "$git_dir/..")/$HOME/'~'}
+      sub_dir=${$(pwd)#$(readlink -f "$git_dir/..")}
+    fi
 
-    sub_dir=$(git rev-parse --show-prefix)
-    sub_dir=${sub_dir%/}
+    sub_dir=${sub_dir#/}
     ref=$(git symbolic-ref HEAD 2> /dev/null) || return
 
     action=""