]> git.donarmstrong.com Git - zsh.git/blobdiff - .zsh/zshrc/60_vcsprompt
Merge remote-tracking branch 'madduck/master'
[zsh.git] / .zsh / zshrc / 60_vcsprompt
index b5ab68ca5b1d31d902e1262be87fff4a486cbe72..f7f80ca807acf818da50d8ba91d211417d99f561 100644 (file)
@@ -16,13 +16,9 @@ __git_get_reporoot()
 {
   # return the full path to the root of the current git repository
   [ -d "$GIT_DIR" ] && echo "$GIT_DIR" && return 0
-  local relroot
-  relroot="$(git rev-parse --show-cdup 2>/dev/null)" || return 1
-  if [ -n "$relroot" ]; then
-    readlink -f "$relroot"
-  else
-    echo $PWD
-  fi
+  local dir; dir="$PWD/$(git rev-parse --show-cdup)"
+  # do not use --show-toplevel because it resolves symlinks
+  echo $dir:a
 }
 
 __git_get_branch()
@@ -160,12 +156,19 @@ __vcs_set_prompt_variables()
         { error "could not determine git repository root"; return 1 }
       branch="$(__git_get_branch)" ||
         { error "could not determine git branch"; return 1 }
-      eval set -- $(__vcs_get_prompt_path_components "$reporoot" "$branch")
-      if [ -d "$GIT_DIR" ]; then
-        # poor man's replace until I find out how to do named dirs properly
-        # here:
-        local _D="${GIT_DIR/$HOME/~}"
-        set -- "$_D" "$2" "${${1#$_D}%/}"
+      if [ -n "$VCSH_REPO_NAME" ]; then
+        # if vcsh is used to get a subshell, then the repo root is the home
+        # directory, but we want to indicate the vcsh context too:
+        eval set -- $(__vcs_get_prompt_path_components "$HOME" "$branch")
+        set -- "vcsh:$VCSH_REPO_NAME" "$2" "$3"
+      else
+        eval set -- $(__vcs_get_prompt_path_components "$reporoot" "$branch")
+        if [ -d "$GIT_DIR" ]; then
+          # poor man's replace until I find out how to do named dirs properly
+          # here:
+          local _D="${GIT_DIR/$HOME/~}"
+          set -- "$_D" "$2" "${${1#$_D}%/}"
+        fi
       fi
       ;;
     hg)