diff options
Diffstat (limited to 'Functions')
20 files changed, 42 insertions, 26 deletions
diff --git a/Functions/VCS_Info/.distfiles b/Functions/VCS_Info/.distfiles index b4118ac80..879aa1eda 100644 --- a/Functions/VCS_Info/.distfiles +++ b/Functions/VCS_Info/.distfiles @@ -5,6 +5,7 @@ VCS_INFO_adjust VCS_INFO_bydir_detect VCS_INFO_check_com VCS_INFO_formats +VCS_INFO_get_cmd vcs_info_lastmsg VCS_INFO_maxexports VCS_INFO_nvcsformats diff --git a/Functions/VCS_Info/Backends/VCS_INFO_detect_cdv b/Functions/VCS_Info/Backends/VCS_INFO_detect_cdv index 356bd069c..a0324533a 100644 --- a/Functions/VCS_Info/Backends/VCS_INFO_detect_cdv +++ b/Functions/VCS_Info/Backends/VCS_INFO_detect_cdv @@ -6,7 +6,7 @@ setopt localoptions NO_shwordsplit [[ $1 == '--flavours' ]] && return 1 -VCS_INFO_check_com cdv || return 1 +VCS_INFO_check_com ${vcs_comm[cmd]} || return 1 vcs_comm[detect_need_file]=format VCS_INFO_bydir_detect '.cdv' return $? diff --git a/Functions/VCS_Info/Backends/VCS_INFO_detect_cvs b/Functions/VCS_Info/Backends/VCS_INFO_detect_cvs index 61b43cc43..7a5ee1eef 100644 --- a/Functions/VCS_Info/Backends/VCS_INFO_detect_cvs +++ b/Functions/VCS_Info/Backends/VCS_INFO_detect_cvs @@ -6,6 +6,6 @@ setopt localoptions NO_shwordsplit [[ $1 == '--flavours' ]] && return 1 -VCS_INFO_check_com svn || return 1 +VCS_INFO_check_com ${vcs_comm[cmd]} || return 1 [[ -d "./CVS" ]] && [[ -r "./CVS/Repository" ]] && return 0 return 1 diff --git a/Functions/VCS_Info/Backends/VCS_INFO_detect_darcs b/Functions/VCS_Info/Backends/VCS_INFO_detect_darcs index 942d8afbb..1e3f5476e 100644 --- a/Functions/VCS_Info/Backends/VCS_INFO_detect_darcs +++ b/Functions/VCS_Info/Backends/VCS_INFO_detect_darcs @@ -6,7 +6,7 @@ setopt localoptions NO_shwordsplit [[ $1 == '--flavours' ]] && return 1 -VCS_INFO_check_com darcs || return 1 +VCS_INFO_check_com ${vcs_comm[cmd]} || return 1 vcs_comm[detect_need_file]=format VCS_INFO_bydir_detect '_darcs' return $? diff --git a/Functions/VCS_Info/Backends/VCS_INFO_detect_git b/Functions/VCS_Info/Backends/VCS_INFO_detect_git index 627b8cf23..61bc483e3 100644 --- a/Functions/VCS_Info/Backends/VCS_INFO_detect_git +++ b/Functions/VCS_Info/Backends/VCS_INFO_detect_git @@ -6,8 +6,8 @@ setopt localoptions NO_shwordsplit [[ $1 == '--flavours' ]] && { print -l git-p4 git-svn; return 0 } -if VCS_INFO_check_com git && git rev-parse --is-inside-work-tree &> /dev/null ; then - vcs_comm[gitdir]="$(git rev-parse --git-dir 2> /dev/null)" || return 1 +if VCS_INFO_check_com ${vcs_comm[cmd]} && ${vcs_comm[cmd]} rev-parse --is-inside-work-tree &> /dev/null ; then + vcs_comm[gitdir]="$(${vcs_comm[cmd]} rev-parse --git-dir 2> /dev/null)" || return 1 if [[ -d ${vcs_comm[gitdir]}/svn ]] ; then vcs_comm[overwrite_name]='git-svn' elif [[ -d ${vcs_comm[gitdir]}/refs/remotes/p4 ]] ; then vcs_comm[overwrite_name]='git-p4' ; fi return 0 diff --git a/Functions/VCS_Info/Backends/VCS_INFO_detect_hg b/Functions/VCS_Info/Backends/VCS_INFO_detect_hg index 8a6c0c8a6..41fcc4b4c 100644 --- a/Functions/VCS_Info/Backends/VCS_INFO_detect_hg +++ b/Functions/VCS_Info/Backends/VCS_INFO_detect_hg @@ -6,7 +6,7 @@ setopt localoptions NO_shwordsplit [[ $1 == '--flavours' ]] && return 1 -VCS_INFO_check_com hg || return 1 +VCS_INFO_check_com ${vcs_comm[cmd]} || return 1 vcs_comm[detect_need_file]=branch VCS_INFO_bydir_detect '.hg' return $? diff --git a/Functions/VCS_Info/Backends/VCS_INFO_detect_mtn b/Functions/VCS_Info/Backends/VCS_INFO_detect_mtn index cb0fec1bd..3f88ba2ea 100644 --- a/Functions/VCS_Info/Backends/VCS_INFO_detect_mtn +++ b/Functions/VCS_Info/Backends/VCS_INFO_detect_mtn @@ -6,7 +6,7 @@ setopt localoptions NO_shwordsplit [[ $1 == '--flavours' ]] && return 1 -VCS_INFO_check_com mtn || return 1 +VCS_INFO_check_com ${vcs_comm[cmd]} || return 1 vcs_comm[detect_need_file]=revision VCS_INFO_bydir_detect '_MTN' return $? diff --git a/Functions/VCS_Info/Backends/VCS_INFO_detect_p4 b/Functions/VCS_Info/Backends/VCS_INFO_detect_p4 index d9475fa01..377453f6a 100644 --- a/Functions/VCS_Info/Backends/VCS_INFO_detect_p4 +++ b/Functions/VCS_Info/Backends/VCS_INFO_detect_p4 @@ -21,7 +21,7 @@ VCS_INFO_p4_get_server() { setopt extendedglob local -a settings - settings=(${(f)"$(p4 set)"}) + settings=(${(f)"$(${vcs_comm[cmd]} set)"}) serverport=${${settings[(r)P4PORT=*]##P4PORT=}%% *} case $serverport in (''|:) @@ -54,7 +54,7 @@ VCS_INFO_detect_p4() { VCS_INFO_p4_get_server [[ -n $vcs_info_p4_dead_servers[$serverport] ]] && return 1 fi - if p4where="$(p4 where 2>&1)"; then + if p4where="$(${vcs_comm[cmd]} where 2>&1)"; then return 0 fi if [[ $p4where = *"Connect to server failed"* ]]; then @@ -67,7 +67,7 @@ VCS_INFO_detect_p4() { return 1 else [[ -n ${P4CONFIG} ]] || return 1 - VCS_INFO_check_com p4 || return 1 + VCS_INFO_check_com ${vcs_comm[cmd]} || return 1 vcs_comm[detect_need_file]="${P4CONFIG}" VCS_INFO_bydir_detect . return $? diff --git a/Functions/VCS_Info/Backends/VCS_INFO_detect_svk b/Functions/VCS_Info/Backends/VCS_INFO_detect_svk index 476b59101..e21b2dd73 100644 --- a/Functions/VCS_Info/Backends/VCS_INFO_detect_svk +++ b/Functions/VCS_Info/Backends/VCS_INFO_detect_svk @@ -17,7 +17,7 @@ setopt localoptions noksharrays extendedglob local -i fhash fhash=0 -VCS_INFO_check_com svk || return 1 +VCS_INFO_check_com ${vcs_comm[cmd]} || return 1 [[ -f ~/.svk/config ]] || return 1 while IFS= read -r line ; do diff --git a/Functions/VCS_Info/Backends/VCS_INFO_detect_svn b/Functions/VCS_Info/Backends/VCS_INFO_detect_svn index f22c34ee5..bb9d083ac 100644 --- a/Functions/VCS_Info/Backends/VCS_INFO_detect_svn +++ b/Functions/VCS_Info/Backends/VCS_INFO_detect_svn @@ -6,6 +6,6 @@ setopt localoptions NO_shwordsplit [[ $1 == '--flavours' ]] && return 1 -VCS_INFO_check_com svn || return 1 +VCS_INFO_check_com ${vcs_comm[cmd]} || return 1 [[ -d ".svn" ]] && return 0 return 1 diff --git a/Functions/VCS_Info/Backends/VCS_INFO_detect_tla b/Functions/VCS_Info/Backends/VCS_INFO_detect_tla index 3b2042897..ac4dbd736 100644 --- a/Functions/VCS_Info/Backends/VCS_INFO_detect_tla +++ b/Functions/VCS_Info/Backends/VCS_INFO_detect_tla @@ -6,6 +6,6 @@ setopt localoptions NO_shwordsplit [[ $1 == '--flavours' ]] && return 1 -VCS_INFO_check_com tla || return 1 -vcs_comm[basedir]="$(tla tree-root 2> /dev/null)" && return 0 +VCS_INFO_check_com ${vcs_comm[cmd]} || return 1 +vcs_comm[basedir]="$(${vcs_comm[cmd]} tree-root 2> /dev/null)" && return 0 return 1 diff --git a/Functions/VCS_Info/Backends/VCS_INFO_get_data_bzr b/Functions/VCS_Info/Backends/VCS_INFO_get_data_bzr index 995b2ad2d..31618d353 100644 --- a/Functions/VCS_Info/Backends/VCS_INFO_get_data_bzr +++ b/Functions/VCS_Info/Backends/VCS_INFO_get_data_bzr @@ -14,8 +14,8 @@ if zstyle -t ":vcs_info:${vcs}:${usercontext}:${rrn}" "use-simple" ; then bzrinfo[1]=${${bzrinfo[1]}%% *} fi else - bzrbase=${${(M)${(f)"$( bzr info )"}:# ##branch\ root:*}/*: ##/} - bzrinfo=( ${${${(M)${(f)"$( bzr version-info )"}:#(#s)(revno|branch-nick)*}/*: /}/*\//} ) + bzrbase=${${(M)${(f)"$( ${vcs_comm[cmd]} info )"}:# ##branch\ root:*}/*: ##/} + bzrinfo=( ${${${(M)${(f)"$( ${vcs_comm[cmd]} version-info )"}:#(#s)(revno|branch-nick)*}/*: /}/*\//} ) bzrbase="$(VCS_INFO_realpath ${bzrbase})" fi diff --git a/Functions/VCS_Info/Backends/VCS_INFO_get_data_git b/Functions/VCS_Info/Backends/VCS_INFO_get_data_git index 0d8a4f915..23545e53c 100644 --- a/Functions/VCS_Info/Backends/VCS_INFO_get_data_git +++ b/Functions/VCS_Info/Backends/VCS_INFO_get_data_git @@ -55,7 +55,7 @@ VCS_INFO_git_getaction () { VCS_INFO_git_getbranch () { local gitbranch gitdir=$1 - local gitsymref='git symbolic-ref HEAD' + local gitsymref="${vcs_comm[cmd]} symbolic-ref HEAD" if [[ -d "${gitdir}/rebase-apply" ]] \ || [[ -d "${gitdir}/rebase" ]] \ @@ -77,7 +77,7 @@ VCS_INFO_git_getbranch () { gitbranch="$(${(z)gitsymref} 2> /dev/null)" if [[ $? -ne 0 ]] ; then - gitbranch="$(git describe --exact-match HEAD 2>/dev/null)" + gitbranch="$(${vcs_comm[cmd]} describe --exact-match HEAD 2>/dev/null)" if [[ $? -ne 0 ]] ; then gitbranch="${${"$(< $gitdir/HEAD)"}[1,7]}..." @@ -98,7 +98,7 @@ fi VCS_INFO_adjust gitaction="$(VCS_INFO_git_getaction ${gitdir})" -gitbase=${PWD%/${$( git rev-parse --show-prefix )%/##}} +gitbase=${PWD%/${$( ${vcs_comm[cmd]} rev-parse --show-prefix )%/##}} rrn=${gitbase:t} VCS_INFO_formats "${gitaction}" "${gitbranch}" "${gitbase}" return 0 diff --git a/Functions/VCS_Info/Backends/VCS_INFO_get_data_mtn b/Functions/VCS_Info/Backends/VCS_INFO_get_data_mtn index 5974df87a..688c85eec 100644 --- a/Functions/VCS_Info/Backends/VCS_INFO_get_data_mtn +++ b/Functions/VCS_Info/Backends/VCS_INFO_get_data_mtn @@ -7,6 +7,6 @@ local mtnbranch mtnbase mtnbase=${vcs_comm[basedir]} rrn=${mtnbase:t} -mtnbranch=${${(M)${(f)"$( mtn status )"}:#(#s)Current branch:*}/*: /} +mtnbranch=${${(M)${(f)"$( ${vcs_comm[cmd]} status )"}:#(#s)Current branch:*}/*: /} VCS_INFO_formats '' "${mtnbranch}" "${mtnbase}" return 0 diff --git a/Functions/VCS_Info/Backends/VCS_INFO_get_data_p4 b/Functions/VCS_Info/Backends/VCS_INFO_get_data_p4 index 077306aa1..dccd9d340 100644 --- a/Functions/VCS_Info/Backends/VCS_INFO_get_data_p4 +++ b/Functions/VCS_Info/Backends/VCS_INFO_get_data_p4 @@ -7,7 +7,7 @@ setopt localoptions extendedglob local p4base a b local -A p4info -p4 info | while IFS=: read a b; do p4info[${a// /_}]="${b## #}"; done +${vcs_comm[cmd]} info | while IFS=: read a b; do p4info[${a// /_}]="${b## #}"; done p4base=${vcs_comm[basedir]} # We'll use the client name as the branch; close enough. @@ -15,7 +15,7 @@ local p4branch change # We'll use the latest change number to which the hierarchy from # here down is synced as the revision. # I suppose the following might be slow on a tortuous client view. -change="${${$(p4 changes -m 1 ...\#have)##Change }%% *}" +change="${${$(${vcs_comm[cmd]} changes -m 1 ...\#have)##Change }%% *}" zstyle -s ":vcs_info:${vcs}:${usercontext}:${rrn}" branchformat p4branch || p4branch="%b:%r" zformat -f p4branch "${p4branch}" "b:${p4info[Client_name]}" \ diff --git a/Functions/VCS_Info/Backends/VCS_INFO_get_data_svn b/Functions/VCS_Info/Backends/VCS_INFO_get_data_svn index 7a23419b0..57ff5d8a1 100644 --- a/Functions/VCS_Info/Backends/VCS_INFO_get_data_svn +++ b/Functions/VCS_Info/Backends/VCS_INFO_get_data_svn @@ -10,10 +10,10 @@ local -A svninfo parentinfo svnbase="."; svninfo=() -svn info --non-interactive | while IFS=: read a b; do svninfo[${a// /_}]="${b## #}"; done +${vcs_comm[cmd]} info --non-interactive | while IFS=: read a b; do svninfo[${a// /_}]="${b## #}"; done while [[ -d "${svnbase}/../.svn" ]]; do parentinfo=() - svn info --non-interactive "${svnbase}/.." | while IFS=: read a b; do parentinfo[${a// /_}]="${b## #}"; done + ${vcs_comm[cmd]} info --non-interactive "${svnbase}/.." | while IFS=: read a b; do parentinfo[${a// /_}]="${b## #}"; done [[ ${parentinfo[Repository_UUID]} != ${svninfo[Repository_UUID]} ]] && break svninfo=(${(kv)parentinfo}) svnbase="${svnbase}/.." diff --git a/Functions/VCS_Info/Backends/VCS_INFO_get_data_tla b/Functions/VCS_Info/Backends/VCS_INFO_get_data_tla index e1921725f..cbc48c0a2 100644 --- a/Functions/VCS_Info/Backends/VCS_INFO_get_data_tla +++ b/Functions/VCS_Info/Backends/VCS_INFO_get_data_tla @@ -8,6 +8,6 @@ local tlabase tlabranch tlabase="$(VCS_INFO_realpath ${vcs_comm[basedir]})" rrn=${tlabase:t} # tree-id gives us something like 'foo@example.com/demo--1.0--patch-4', so: -tlabranch=${${"$( tla tree-id )"}/*\//} +tlabranch=${${"$( ${vcs_comm[cmd]} tree-id )"}/*\//} VCS_INFO_formats '' "${tlabranch}" "${tlabase}" return 0 diff --git a/Functions/VCS_Info/VCS_INFO_check_com b/Functions/VCS_Info/VCS_INFO_check_com index 6d65360d5..d9f7a1330 100644 --- a/Functions/VCS_Info/VCS_INFO_check_com +++ b/Functions/VCS_Info/VCS_INFO_check_com @@ -4,5 +4,12 @@ setopt localoptions NO_shwordsplit -(( ${+commands[$1]} )) && [[ -x ${commands[$1]} ]] && return 0 +case $1 in + (/*) + [[ -x $1 ]] && return 0 + ;; + (*) + (( ${+commands[$1]} )) && [[ -x ${commands[$1]} ]] && return 0 +esac + return 1 diff --git a/Functions/VCS_Info/VCS_INFO_get_cmd b/Functions/VCS_Info/VCS_INFO_get_cmd new file mode 100644 index 000000000..26046f1c5 --- /dev/null +++ b/Functions/VCS_Info/VCS_INFO_get_cmd @@ -0,0 +1,6 @@ +## vim:ft=zsh +# find out if the user wants us to use a special binary. +# the default command name is the same as the backend name. +local cmd +zstyle -s ":vcs_info:${vcs}:${usercontext}:${rrn}" "command" cmd +vcs_comm[cmd]=${cmd:-$vcs} diff --git a/Functions/VCS_Info/vcs_info b/Functions/VCS_Info/vcs_info index fb87e6a54..7ecd1224a 100644 --- a/Functions/VCS_Info/vcs_info +++ b/Functions/VCS_Info/vcs_info @@ -17,6 +17,7 @@ static_functions=( VCS_INFO_bydir_detect VCS_INFO_check_com VCS_INFO_formats + VCS_INFO_get_cmd VCS_INFO_maxexports VCS_INFO_nvcsformats VCS_INFO_realpath @@ -74,6 +75,7 @@ vcs_info () { continue fi vcs_comm=() + VCS_INFO_get_cmd VCS_INFO_detect_${vcs} && (( found = 1 )) && break done |