summaryrefslogtreecommitdiff
path: root/Functions/VCS_Info
diff options
context:
space:
mode:
Diffstat (limited to 'Functions/VCS_Info')
-rw-r--r--Functions/VCS_Info/Backends/VCS_INFO_detect_hg2
-rw-r--r--Functions/VCS_Info/Backends/VCS_INFO_get_data_git33
-rw-r--r--Functions/VCS_Info/Backends/VCS_INFO_get_data_svn30
3 files changed, 46 insertions, 19 deletions
diff --git a/Functions/VCS_Info/Backends/VCS_INFO_detect_hg b/Functions/VCS_Info/Backends/VCS_INFO_detect_hg
index a22c1ee0f..d7b1d0d36 100644
--- a/Functions/VCS_Info/Backends/VCS_INFO_detect_hg
+++ b/Functions/VCS_Info/Backends/VCS_INFO_detect_hg
@@ -7,7 +7,7 @@ setopt localoptions NO_shwordsplit
[[ $1 == '--flavours' ]] && { print -l hg-git hg-hgsubversion hg-hgsvn; return 0 }
VCS_INFO_check_com ${vcs_comm[cmd]} || return 1
-vcs_comm[detect_need_file]="store data"
+vcs_comm[detect_need_file]="store data sharedpath"
VCS_INFO_bydir_detect '.hg' || return 1
if [[ -d ${vcs_comm[basedir]}/.hg/svn ]] ; then
diff --git a/Functions/VCS_Info/Backends/VCS_INFO_get_data_git b/Functions/VCS_Info/Backends/VCS_INFO_get_data_git
index e6791cb7a..76ab92f33 100644
--- a/Functions/VCS_Info/Backends/VCS_INFO_get_data_git
+++ b/Functions/VCS_Info/Backends/VCS_INFO_get_data_git
@@ -5,6 +5,7 @@
setopt localoptions extendedglob NO_shwordsplit
local gitdir gitbase gitbranch gitaction gitunstaged gitstaged gitsha1
local stgitpatch stgitunapplied
+local -i querystaged queryunstaged
local -A hook_com
VCS_INFO_git_getaction () {
@@ -96,7 +97,7 @@ VCS_INFO_git_getbranch () {
gitbranch="$(${(z)gitsymref} 2> /dev/null)"
if [[ $? -ne 0 ]] ; then
- gitbranch="refs/tags/$(${vcs_comm[cmd]} describe --exact-match HEAD 2>/dev/null)"
+ gitbranch="refs/tags/$(${vcs_comm[cmd]} describe --all --exact-match HEAD 2>/dev/null)"
if [[ $? -ne 0 ]] ; then
gitbranch="${${"$(< $gitdir/HEAD)"}[1,7]}..."
@@ -120,14 +121,30 @@ if [[ -z ${gitdir} ]] || [[ -z ${gitbranch} ]] ; then
return 1
fi
-if zstyle -t ":vcs_info:${vcs}:${usercontext}:${rrn}" "check-for-changes" && \
- [[ "$(${vcs_comm[cmd]} rev-parse --is-inside-git-dir 2> /dev/null)" != 'true' ]] && \
- ${vcs_comm[cmd]} rev-parse --quiet --verify HEAD &> /dev/null ; then
+if zstyle -t ":vcs_info:${vcs}:${usercontext}:${rrn}" "check-for-changes" ; then
+ querystaged=1
+ queryunstaged=1
+elif zstyle -t ":vcs_info:${vcs}:${usercontext}:${rrn}" "check-for-staged-changes" ; then
+ querystaged=1
+fi
+if (( querystaged || queryunstaged )) && \
+ [[ "$(${vcs_comm[cmd]} rev-parse --is-inside-work-tree 2> /dev/null)" == 'true' ]] ; then
# Default: off - these are potentially expensive on big repositories
- ${vcs_comm[cmd]} diff --no-ext-diff --ignore-submodules --quiet --exit-code ||
- gitunstaged=1
- ${vcs_comm[cmd]} diff-index --cached --quiet --ignore-submodules HEAD 2> /dev/null
- (( $? && $? != 128 )) && gitstaged=1
+ if (( queryunstaged )) ; then
+ ${vcs_comm[cmd]} diff --no-ext-diff --ignore-submodules --quiet --exit-code ||
+ gitunstaged=1
+ fi
+ if (( querystaged )) ; then
+ if ${vcs_comm[cmd]} rev-parse --quiet --verify HEAD &> /dev/null ; then
+ ${vcs_comm[cmd]} diff-index --cached --quiet --ignore-submodules HEAD 2> /dev/null
+ (( $? && $? != 128 )) && gitstaged=1
+ else
+ # empty repository (no commits yet)
+ # 4b825dc642cb6eb9a060e54bf8d69288fbee4904 is the git empty tree.
+ ${vcs_comm[cmd]} diff-index --cached --quiet --ignore-submodules 4b825dc642cb6eb9a060e54bf8d69288fbee4904 2>/dev/null
+ (( $? && $? != 128 )) && gitstaged=1
+ fi
+ fi
fi
VCS_INFO_adjust
diff --git a/Functions/VCS_Info/Backends/VCS_INFO_get_data_svn b/Functions/VCS_Info/Backends/VCS_INFO_get_data_svn
index 41cc3e783..e56afee02 100644
--- a/Functions/VCS_Info/Backends/VCS_INFO_get_data_svn
+++ b/Functions/VCS_Info/Backends/VCS_INFO_get_data_svn
@@ -7,7 +7,7 @@
setopt localoptions noksharrays extendedglob NO_shwordsplit
local svnbase svnbranch a b rrn
local -i rc
-local -A svninfo parentinfo
+local -A svninfo parentinfo cwdinfo
local -xA hook_com
svnbase=".";
@@ -28,24 +28,34 @@ done
#rc=${pipestatus[1]}
#(( rc != 0 )) && return 1
-while [[ -d "${svnbase}/../.svn" ]]; do
- parentinfo=()
- ${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}/.."
-done
+cwdinfo=(${(kv)svninfo})
+
+# Set svnbase to the wcroot path and svninfo to its `svn info`.
+if (( ${+svninfo[Working_Copy_Root_Path]} )); then
+ # svn 1.7+
+ svnbase=${svninfo[Working_Copy_Root_Path]}
+ ${vcs_comm[cmd]} info --non-interactive -- "${svnbase}" | while IFS=: read a b; do svninfo[${a// /_}]="${b## #}"; done
+else
+ # svn 1.0-1.6
+ while [[ -d "${svnbase}/../.svn" ]]; do
+ parentinfo=()
+ ${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}/.."
+ done
+fi
svnbase="$(VCS_INFO_realpath ${svnbase})"
rrn=${svnbase:t}
zstyle -s ":vcs_info:${vcs}:${usercontext}:${rrn}" branchformat svnbranch || svnbranch="%b:%r"
-hook_com=( branch "${svninfo[URL]##*/}" revision "${svninfo[Revision]}" )
+hook_com=( branch "${svninfo[URL]##*/}" revision "${cwdinfo[Revision]}" )
if VCS_INFO_hook 'set-branch-format' "${svnbranch}"; then
zformat -f svnbranch "${svnbranch}" "b:${hook_com[branch]}" "r:${hook_com[revision]}"
else
svnbranch=${hook_com[branch-replace]}
fi
hook_com=()
-VCS_INFO_formats '' "${svnbranch}" "${svnbase}" '' '' "${svninfo[Revision]}" ''
+VCS_INFO_formats '' "${svnbranch}" "${svnbase}" '' '' "${cwdinfo[Revision]}" ''
return 0