summaryrefslogtreecommitdiff
path: root/Functions/VCS_Info/Backends
diff options
context:
space:
mode:
authorAxel Beckert <abe@deuxchevaux.org>2018-12-24 04:40:22 +0100
committerAxel Beckert <abe@deuxchevaux.org>2018-12-24 04:40:22 +0100
commitbf8b7f713a5b04a191f4596fb86bbbfca0a855ce (patch)
treeb647a8dc990c8c845b8a8eca7bf92fbbf17e1fb5 /Functions/VCS_Info/Backends
parent06946d431a4426c6e5dffec1d7edb17c1dbd467c (diff)
parent9dbde9e9c7d22ee0d301e4a2fecf97906d1ddce9 (diff)
downloadzsh-bf8b7f713a5b04a191f4596fb86bbbfca0a855ce.tar.gz
zsh-bf8b7f713a5b04a191f4596fb86bbbfca0a855ce.zip
New upstream release candidate 5.6.2-test-2
Merge branch 'upstream' at 'zsh-5.6.2-test-2' into branch debian
Diffstat (limited to 'Functions/VCS_Info/Backends')
-rw-r--r--Functions/VCS_Info/Backends/VCS_INFO_detect_p42
-rw-r--r--Functions/VCS_Info/Backends/VCS_INFO_get_data_bzr3
-rw-r--r--Functions/VCS_Info/Backends/VCS_INFO_get_data_git74
-rw-r--r--Functions/VCS_Info/Backends/VCS_INFO_get_data_svn11
4 files changed, 70 insertions, 20 deletions
diff --git a/Functions/VCS_Info/Backends/VCS_INFO_detect_p4 b/Functions/VCS_Info/Backends/VCS_INFO_detect_p4
index 95a534786..d171c68ee 100644
--- a/Functions/VCS_Info/Backends/VCS_INFO_detect_p4
+++ b/Functions/VCS_Info/Backends/VCS_INFO_detect_p4
@@ -16,6 +16,7 @@
# of having such files in all client root directories and nowhere above.
+(( ${+functions[VCS_INFO_p4_get_server]} )) ||
VCS_INFO_p4_get_server() {
emulate -L zsh
setopt extendedglob
@@ -43,6 +44,7 @@ VCS_INFO_p4_get_server() {
}
+(( ${+functions[VCS_INFO_detect_p4]} )) ||
VCS_INFO_detect_p4() {
local serverport p4where
diff --git a/Functions/VCS_Info/Backends/VCS_INFO_get_data_bzr b/Functions/VCS_Info/Backends/VCS_INFO_get_data_bzr
index 705db65a7..b30e0e12b 100644
--- a/Functions/VCS_Info/Backends/VCS_INFO_get_data_bzr
+++ b/Functions/VCS_Info/Backends/VCS_INFO_get_data_bzr
@@ -8,6 +8,7 @@ local bzrbase bzrbr bzr_changes bzr_type
local -a bzrinfo
local -A hook_com bzr_info
+(( ${+functions[VCS_INFO_bzr_get_info]} )) ||
VCS_INFO_bzr_get_info() {
bzrinfo=( ${(s.:.)$( ${vcs_comm[cmd]} version-info --custom \
--template="{revno}:{branch_nick}:{clean}")} )
@@ -20,6 +21,7 @@ VCS_INFO_bzr_get_info() {
fi
}
+(( ${+functions[VCS_INFO_bzr_get_info_restricted]} )) ||
VCS_INFO_bzr_get_info_restricted() {
# we are forbidden from fetching info on bound branch from remote repository
bzrinfo=( $(${vcs_comm[cmd]} revno) ${bzrbase:t} )
@@ -30,6 +32,7 @@ VCS_INFO_bzr_get_info_restricted() {
fi
}
+(( ${+functions[VCS_INFO_bzr_get_changes]} )) ||
VCS_INFO_bzr_get_changes() {
local -A counts
local line flag
diff --git a/Functions/VCS_Info/Backends/VCS_INFO_get_data_git b/Functions/VCS_Info/Backends/VCS_INFO_get_data_git
index c3e62db3a..ceb4f978a 100644
--- a/Functions/VCS_Info/Backends/VCS_INFO_get_data_git
+++ b/Functions/VCS_Info/Backends/VCS_INFO_get_data_git
@@ -8,6 +8,7 @@ local -i querystaged queryunstaged
local -a git_patches_applied git_patches_unapplied
local -A hook_com
+(( ${+functions[VCS_INFO_git_getaction]} )) ||
VCS_INFO_git_getaction () {
local gitdir=$1
local tmp
@@ -70,6 +71,7 @@ VCS_INFO_git_getaction () {
return 1
}
+(( ${+functions[VCS_INFO_git_getbranch]} )) ||
VCS_INFO_git_getbranch () {
local gitdir=$1 tmp actiondir
local gitsymref="${vcs_comm[cmd]} symbolic-ref HEAD"
@@ -87,8 +89,8 @@ VCS_INFO_git_getbranch () {
gitbranch="$(${(z)gitsymref} 2> /dev/null)"
[[ -z ${gitbranch} ]] && [[ -r ${actiondir}/head-name ]] \
&& gitbranch="$(< ${actiondir}/head-name)"
- [[ -z ${gitbranch} || ${gitbranch} == 'detached HEAD' ]] \
- && gitbranch="$(< ${gitdir}/ORIG_HEAD)"
+ [[ -z ${gitbranch} || ${gitbranch} == 'detached HEAD' ]] && [[ -r ${actiondir}/onto ]] \
+ && gitbranch="$(< ${actiondir}/onto)"
elif [[ -f "${gitdir}/MERGE_HEAD" ]] ; then
gitbranch="$(${(z)gitsymref} 2> /dev/null)"
@@ -110,18 +112,22 @@ VCS_INFO_git_getbranch () {
## Commented out because we don't know of a case in which 'describe --contains' fails and 'name-rev --tags' succeeds.
#elif gitbranch="$(${vcs_comm[cmd]} name-rev --name-only --no-undefined --tags HEAD 2>/dev/null)" ; then
elif gitbranch="$(${vcs_comm[cmd]} name-rev --name-only --no-undefined --always HEAD 2>/dev/null)" ; then
- elif gitbranch="${${"$(< $gitdir/HEAD)"}[1,7]}..." ; then
- else
- # Can't happen
+ fi
+
+ if [[ -z ${gitbranch} ]]
+ then
+ gitbranch="${${"$(< $gitdir/HEAD)"}[1,7]}..."
fi
return 0
}
+(( ${+functions[VCS_INFO_git_handle_patches]} )) ||
VCS_INFO_git_handle_patches () {
local git_applied_s git_unapplied_s gitmsg
+ # All callers populate $git_patches_applied and $git_patches_unapplied in
+ # order, but the hook requires us to reverse $git_patches_applied.
git_patches_applied=(${(Oa)git_patches_applied})
- git_patches_unapplied=(${(Oa)git_patches_unapplied})
VCS_INFO_set-patch-format 'git_patches_applied' 'git_applied_s' \
'git_patches_unapplied' 'git_unapplied_s' \
@@ -183,6 +189,7 @@ then
git_patches_unapplied=(${(f)"$(< "${patchdir}/unapplied")"})
VCS_INFO_git_handle_patches
elif [[ -d "${gitdir}/rebase-merge" ]]; then
+ # 'git rebase -i'
patchdir="${gitdir}/rebase-merge"
local p
[[ -f "${patchdir}/done" ]] &&
@@ -190,21 +197,57 @@ elif [[ -d "${gitdir}/rebase-merge" ]]; then
# pick/edit/fixup/squash/reword: Add "$hash $subject" to $git_patches_applied.
# exec: Add "exec ${command}" to $git_patches_applied.
# (anything else): As 'exec'.
- p=${p/(#s)(p|pick|e|edit|r|reword|f|fixup|s|squash) /}
- p=${p/(#s)x /exec }
+ case $p in
+ ((p|pick|e|edit|r|reword|f|fixup|s|squash)' '*)
+ # The line is of the form "pick $hash $subject".
+ # Just strip the verb and we're good to go.
+ p=${p#* }
+ # Special case: in an interactive rebase, if the user wrote "p $shorthash\n"
+ # in the editor (without a description after the hash), then the .../done
+ # file will contain "p $longhash $shorthash\n" (git 2.11.0) or "pick $longhash\n"
+ # (git 2.19.0).
+ if [[ $p != *\ * ]]; then
+ # The line is of the form "pick $longhash\n"
+ #
+ # Mark the log message subject as unknown.
+ # TODO: Can we performantly obtain the subject?
+ p+=" ?"
+ elif (( ${#${p//[^ ]}} == 1 )) && [[ ${p%% *} == ${p#* }* ]]; then
+ # The line is of the form "p $longhash $shorthash\n"
+ #
+ # The shorthash is superfluous, so discard it, and mark
+ # the log message subject as unknown.
+ # TODO: Can we performantly obtain the subject?
+ p="${p%% *} ?"
+ fi
+ ;;
+ (x *)
+ # The line is of the form 'exec foo bar baz' where 'foo bar
+ # baz' is a shell command. There's no way to map _that_ to
+ # "$hash $subject", but I hope this counts as making an effort.
+ p=${p/x /exec }
+ ;;
+ (*)
+ # Forward compatibility with not-yet-existing 'git rebase -i' verbs.
+ if [[ $p != *\ * ]]; then
+ p+=" ?"
+ fi
+ esac
git_patches_applied+=("$p")
done
if [[ -f "${patchdir}/git-rebase-todo" ]] ; then
+ # TODO: Process ${patchdir}/git-rebase-todo lines like ${patchdir}/done lines are
git_patches_unapplied=( ${${(f)${"$(<"${patchdir}/git-rebase-todo")"}}:#[#]*} )
fi
VCS_INFO_git_handle_patches
elif [[ -d "${gitdir}/rebase-apply" ]]; then
- # Fake patch names for all but current patch
+ # 'git rebase' without -i
patchdir="${gitdir}/rebase-apply"
local next="${patchdir}/next"
if [[ -f $next ]]; then
local cur=$(< $next)
local p subject
+ # Fake patch names for all but current patch
for ((p = 1; p < cur; p++)); do
printf -v "git_patches_applied[$p]" "%04d ?" "$p"
done
@@ -220,18 +263,11 @@ elif [[ -d "${gitdir}/rebase-apply" ]]; then
subject=$REPLY
}
fi
+ subject=${subject:-'?'}
if [[ -f "${patchdir}/original-commit" ]]; then
- if [[ -n $subject ]]; then
- git_patches_applied+=("$(< ${patchdir}/original-commit) $subject")
- else
- git_patches_applied+=("$(< ${patchdir}/original-commit)")
- fi
+ git_patches_applied+=("$(< ${patchdir}/original-commit) $subject")
else
- if [[ -n $subject ]]; then
- git_patches_applied+=("? $subject")
- else
- git_patches_applied+=("?")
- fi
+ git_patches_applied+=("? $subject")
fi
local last="$(< "${patchdir}/last")"
if (( cur+1 <= last )); then
diff --git a/Functions/VCS_Info/Backends/VCS_INFO_get_data_svn b/Functions/VCS_Info/Backends/VCS_INFO_get_data_svn
index a773a727d..c1547950f 100644
--- a/Functions/VCS_Info/Backends/VCS_INFO_get_data_svn
+++ b/Functions/VCS_Info/Backends/VCS_INFO_get_data_svn
@@ -9,6 +9,7 @@ local svnbase svnbranch a b rrn
local -i rc
local -A svninfo parentinfo cwdinfo
local -A hook_com
+integer -r SVN_ERR_WC_UPGRADE_REQUIRED=155036 # from /usr/local/include/subversion-1/svn_error_codes.h
svnbase=".";
svninfo=()
@@ -18,7 +19,15 @@ svninfo=()
local -a dat
dat=( ${(f)"$(${vcs_comm[cmd]} info --non-interactive 2>&1)"} )
rc=$?
-(( rc != 0 )) && return 1
+if (( rc != 0 )) ; then
+ if (( rc == 1 )) && [[ -n ${(M)dat:#"svn: E${SVN_ERR_WC_UPGRADE_REQUIRED}: "*} ]]; then
+ hook_com=()
+ VCS_INFO_formats '' '?' '?' '' '' '?' 'upgrade required'
+ return $?
+ else
+ return 1
+ fi
+fi
# The following line is the real code, the following is the workaround.
#${vcs_comm[cmd]} info --non-interactive \
print -l "${dat[@]}" \