]> git.donarmstrong.com Git - zsh.git/commitdiff
Proper detection of VCS type
authormartin f. krafft <madduck@madduck.net>
Tue, 6 May 2008 20:47:29 +0000 (21:47 +0100)
committermartin f. krafft <madduck@madduck.net>
Tue, 6 May 2008 20:47:29 +0000 (21:47 +0100)
we can't just run e.g. a git command because that wouldn't find another repo
type in a subdir of a git repo. so we do it iteratively by checking for the
directories, which is suboptimal but should work.

.zsh/zshrc/85_vcs_prompt

index 81e7773ec683be84e63e3115da1d58f86c1ad22b..d99251141f5e69c55e1f9106caa5b52f82882724 100644 (file)
@@ -52,11 +52,15 @@ __get_prompt_path_components()
 
 __vcs_get_repo_type()
 {
-  if __git_get_repo_root >/dev/null; then
-    echo git
-  else
-    echo NONE
-  fi
+  while true; do
+    [ -d .git ] && echo git && break
+    [ -d .bzr ] && echo bzr && break
+    [ -d .hg ] && echo hg && break
+    [ -d .svn ] && echo svn && break
+    [ -d CVS ] && echo cvs && break
+    [ "$PWD" = / ] && echo NONE && return 1
+    cd ..
+  done
 }
 
 __vcs_set_prompt_variables()