+ if [[ -n ${1} ]] ; then
+ zstyle -s ":vcs_info:${vcs}" promptactionformat msg
+ [[ -z ${msg} ]] && msg=' (%s)-[%b|%a]-'
+ else
+ zstyle -s ":vcs_info:${vcs}" promptformat msg
+ [[ -z ${msg} ]] && msg=' (%s)-[%b]-'
+ fi
+ printf '%s' ${msg}
+}
+# }}}
+VCS_INFO_realpath () { #{{{
+ # replacing 'readlink -f', which is really not portable.
+
+ # If there *is* a chpwd() function unfunction it here.
+ # The *real* zsh does not loose its chpwd(), because we run
+ # in a different context (process substitution in $PROMPT).
+ (( ${+functions[chpwd]} )) && unfunction chpwd
+ setopt chaselinks
+ cd $1 2>/dev/null && pwd
+}
+# }}}
+VCS_INFO_git_getaction () { #{{{
+ local gitaction='' gitdir=${1}
+ local tmp
+
+ for tmp in "${gitdir}/rebase-apply" \
+ "${gitdir}/rebase" \
+ "${gitdir}/../.dotest" ; do
+ if [[ -d ${tmp} ]] ; then
+ if [[ -f "${tmp}/rebasing" ]] ; then
+ gitaction="rebase"
+ elif [[ -f "${tmp}/applying" ]] ; then
+ gitaction="am"
+ else
+ gitaction="am/rebase"
+ fi
+ printf '%s' ${gitaction}
+ return 0
+ fi
+ done
+
+ for tmp in "${gitdir}/rebase-merge/interactive" \
+ "${gitdir}/.dotest-merge/interactive" ; do
+ if [[ -f "${tmp}" ]] ; then
+ printf '%s' "rebase-i"
+ return 0
+ fi
+ done
+
+ for tmp in "${gitdir}/rebase-merge" \
+ "${gitdir}/.dotest-merge" ; do
+ if [[ -d "${tmp}" ]] ; then
+ printf '%s' "rebase-m"
+ return 0
+ fi
+ done
+
+ if [[ -f "${gitdir}/MERGE_HEAD" ]] ; then
+ printf '%s' "merge"
+ else
+ if [[ -f "${gitdir}/BISECT_LOG" ]] ; then
+ printf '%s' "bisect"
+ fi
+ fi
+
+ return 1
+}
+# }}}
+VCS_INFO_git_getbranch () { #{{{
+ local gitbranch gitdir=${1}
+ local gitsymref='git symbolic-ref HEAD'
+
+ if [[ -d "${gitdir}/rebase-apply" ]] \
+ || [[ -d "${gitdir}/rebase" ]] \
+ || [[ -d "${gitdir}/../.dotest" ]] \
+ || [[ -f "${gitdir}/MERGE_HEAD" ]] ; then
+ gitbranch="$(${(z)gitsymref} 2> /dev/null)"
+ [[ -z ${gitbranch} ]] && gitbranch="$(< ${gitdir}/rebase-apply/head-name)"
+
+ elif [[ -f "${gitdir}/rebase-merge/interactive" ]] \
+ || [[ -d "${gitdir}/rebase-merge" ]] ; then
+ gitbranch="$(< ${gitdir}/rebase-merge/head-name)"
+
+ elif [[ -f "${gitdir}/.dotest-merge/interactive" ]] \
+ || [[ -d "${gitdir}/.dotest-merge" ]] ; then
+ gitbranch="$(< ${gitdir}/.dotest-merge/head-name)"
+
+ else
+ gitbranch="$(${(z)gitsymref} 2> /dev/null)"
+
+ if [[ $? -ne 0 ]] ; then
+ gitbranch="$(git describe --exact-match HEAD 2>/dev/null)"
+
+ if [[ $? -ne 0 ]] ; then
+ gitbranch="${${"$(< $gitdir/HEAD)"}[1,7]}..."
+ fi
+ fi
+ fi
+
+ printf '%s' "${gitbranch##refs/heads/}"
+}
+# }}}
+VCS_INFO_git_get_data () { # {{{
+ setopt localoptions extendedglob
+ local gitdir gitbase gitbranch gitaction msg
+
+ gitdir=${vcs_comm[gitdir]}
+ gitbranch="$(VCS_INFO_git_getbranch ${gitdir})"
+
+ if [[ -z ${gitdir} ]] || [[ -z ${gitbranch} ]] ; then
+ return
+ fi
+
+ VCS_INFO_adjust
+ gitaction="$(VCS_INFO_git_getaction ${gitdir})"
+ msg=$(VCS_INFO_format ${gitaction})
+
+ gitbase=${PWD%/${$(git rev-parse --show-prefix)%/##}}
+
+ zformat -f msg "${msg}" "a:${gitaction}" "b:${gitbranch}" "s:${vcs}" "r:${gitbase:t}" "R:${gitbase}"
+ printf '%s' ${msg}
+}
+# }}}
+VCS_INFO_darcs_get_data () { # {{{
+ local msg darcsbase
+
+ darcsbase=${vcs_comm[basedir]}
+ msg=$(VCS_INFO_format)
+ zformat -f msg "${msg}" "a:" "b:${darcsbase:t}" "s:${vcs}" "r:${darcsbase:t}" "R:${darcsbase}"
+ printf '%s' ${msg}
+}
+# }}}
+VCS_INFO_hg_get_data () { # {{{
+ local msg hgbranch hgbase
+
+ hgbase=${vcs_comm[basedir]}
+ hgbranch=$(< ${hgbase}/.hg/branch)
+ msg=$(VCS_INFO_format)
+ zformat -f msg "${msg}" "a:" "b:${hgbranch}" "s:${vcs}" "r:${hgbase:t}" "R:${hgbase}"
+ printf '%s' ${msg}
+}
+# }}}
+VCS_INFO_mtn_get_data () { # {{{
+ local msg mtnbranch mtnbase
+
+ mtnbase=${vcs_comm[basedir]}
+ mtnbranch=$(mtn status | awk '/Current branch:/{ sub("Current branch: ", ""); print }')
+ msg=$(VCS_INFO_format)
+ zformat -f msg "${msg}" "a:" "b:${mtnbranch}" "s:${vcs}" "r:${mtnbase:t}" "R:${mtnbase}"
+ printf '%s' ${msg}
+}
+# }}}
+VCS_INFO_svk_get_data () { # {{{
+ local msg svkbranch svkbase
+
+ svkbase=${vcs_comm[basedir]}
+
+ zstyle -s ":vcs_info:${vcs}" branchformat svkbranch || svkbranch="%b:%r"
+ zformat -f svkbranch "${svkbranch}" "b:${vcs_comm[branch]}" "r:${vcs_comm[revision]}"
+
+ msg=$(VCS_INFO_format)
+ zformat -f msg "${msg}" "a:" "b:${svkbranch}" "s:${vcs}" "r:${svkbase:t}" "R:${svkbase}"
+ printf '%s' ${msg}
+}
+# }}}
+VCS_INFO_svn_get_data () { # {{{
+ setopt localoptions noksharrays
+ local msg svnbase svnbranch
+ local -a svninfo
+
+ svnbase="."
+ while [[ -d "${svnbase}/../.svn" ]]; do
+ svnbase="${svnbase}/.."
+ done
+ svnbase=$(VCS_INFO_realpath ${svnbase})
+ svninfo=($(svn info "${svnbase}" | awk '/^URL/ { sub(".*/","",$0); r=$0 } /^Revision/ { sub("[^0-9]*","",$0); print r"\n"$0 }'))
+
+ zstyle -s ":vcs_info:${vcs}" branchformat svnbranch || svnbranch="%b:%r"
+ zformat -f svnbranch "${svnbranch}" "b:${svninfo[1]}" "r:${svninfo[2]}"