diff options
author | Axel Beckert <abe@deuxchevaux.org> | 2018-12-24 04:40:22 +0100 |
---|---|---|
committer | Axel Beckert <abe@deuxchevaux.org> | 2018-12-24 04:40:22 +0100 |
commit | bf8b7f713a5b04a191f4596fb86bbbfca0a855ce (patch) | |
tree | b647a8dc990c8c845b8a8eca7bf92fbbf17e1fb5 /Functions | |
parent | 06946d431a4426c6e5dffec1d7edb17c1dbd467c (diff) | |
parent | 9dbde9e9c7d22ee0d301e4a2fecf97906d1ddce9 (diff) | |
download | zsh-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')
-rw-r--r-- | Functions/Misc/add-zle-hook-widget | 12 | ||||
-rw-r--r-- | Functions/VCS_Info/Backends/VCS_INFO_detect_p4 | 2 | ||||
-rw-r--r-- | Functions/VCS_Info/Backends/VCS_INFO_get_data_bzr | 3 | ||||
-rw-r--r-- | Functions/VCS_Info/Backends/VCS_INFO_get_data_git | 74 | ||||
-rw-r--r-- | Functions/VCS_Info/Backends/VCS_INFO_get_data_svn | 11 | ||||
-rw-r--r-- | Functions/VCS_Info/VCS_INFO_quilt | 7 | ||||
-rw-r--r-- | Functions/VCS_Info/VCS_INFO_set-patch-format | 2 | ||||
-rw-r--r-- | Functions/Zle/edit-command-line | 2 | ||||
-rw-r--r-- | Functions/Zle/select-bracketed | 4 |
9 files changed, 87 insertions, 30 deletions
diff --git a/Functions/Misc/add-zle-hook-widget b/Functions/Misc/add-zle-hook-widget index d8a3950fb..9cc35496f 100644 --- a/Functions/Misc/add-zle-hook-widget +++ b/Functions/Misc/add-zle-hook-widget @@ -129,7 +129,7 @@ function add-zle-hook-widget { else # Check whether attempting to add a widget named for the hook if [[ "$fn" = "$hook" ]]; then - if [[ -n "${widgets[$fn]}" ]]; then + if (( ${+widgets[$fn]} )); then print -u2 "$funcstack[1]: Cannot hook $fn to itself" return 1 fi @@ -141,8 +141,8 @@ function add-zle-hook-widget { integer i=${#options[ksharrays]}-2 zstyle -g extant_hooks "$hook" widgets # Check for an existing widget, add it as the first hook - if [[ ${widgets[$hook]} != "user:azhw:$hook" ]]; then - if [[ -n ${widgets[$hook]} ]]; then + if [[ ${widgets[$hook]:-} != "user:azhw:$hook" ]]; then + if [[ -n ${widgets[$hook]:-} ]]; then zle -A "$hook" "${widgets[$hook]}" extant_hooks=(0:"${widgets[$hook]}" "${extant_hooks[@]}") fi @@ -152,17 +152,17 @@ function add-zle-hook-widget { if [[ -z ${(M)extant_hooks[@]:#(<->:|)$fn} ]]; then # no index and not already hooked # assign largest existing index plus 1 - i=${${(On@)${(@M)extant_hooks[@]#<->:}%:}[i]}+1 + i=${${(On@)${(@M)extant_hooks[@]#<->:}%:}[i]:-0}+1 else return 0 fi extant_hooks+=("${i}:${fn}") zstyle -- "$hook" widgets "${extant_hooks[@]}" - if [[ -z "${widgets[$fn]}" ]]; then + if (( ! ${+widgets[$fn]} )); then autoload "${autoopts[@]}" -- "$fn" zle -N -- "$fn" fi - if [[ -z "${widgets[$hook]}" ]]; then + if (( ! ${+widgets[$hook]} )); then zle -N "$hook" azhw:"$hook" fi fi 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[@]}" \ diff --git a/Functions/VCS_Info/VCS_INFO_quilt b/Functions/VCS_Info/VCS_INFO_quilt index 381b58489..1f20e895d 100644 --- a/Functions/VCS_Info/VCS_INFO_quilt +++ b/Functions/VCS_Info/VCS_INFO_quilt @@ -1,5 +1,6 @@ ## vim:ft=zsh:foldmethod=marker +(( ${+functions[VCS_INFO_quilt-match]} )) || function VCS_INFO_quilt-match() { emulate -L zsh setopt extendedglob @@ -20,6 +21,7 @@ function VCS_INFO_quilt-match() { return 1 } +(( ${+functions[VCS_INFO_quilt-standalone-detect]} )) || function VCS_INFO_quilt-standalone-detect() { emulate -L zsh setopt extendedglob @@ -58,6 +60,7 @@ function VCS_INFO_quilt-standalone-detect() { return 1 } +(( ${+functions[VCS_INFO_quilt-dirfind]} )) || function VCS_INFO_quilt-dirfind() { # This is a wrapper around VCS_INFO_bydir_detect(). It makes sure # that $vcs_comm[] is unchanged. Currently, changing anything in it @@ -80,11 +83,12 @@ function VCS_INFO_quilt-dirfind() { return ${ret} } +(( ${+functions[VCS_INFO_quilt-patch2subject]} )) || function VCS_INFO_quilt-patch2subject() { VCS_INFO_patch2subject "$@" } -function VCS_INFO_quilt() { +{ emulate -L zsh setopt extendedglob local mode="$1" @@ -192,4 +196,3 @@ function VCS_INFO_quilt() { VCS_INFO_hook 'post-quilt' ${mode} ${patches} ${pc:-\\-nopc-} } -VCS_INFO_quilt "$@" diff --git a/Functions/VCS_Info/VCS_INFO_set-patch-format b/Functions/VCS_Info/VCS_INFO_set-patch-format index cdf2d303e..917ebf6bf 100644 --- a/Functions/VCS_Info/VCS_INFO_set-patch-format +++ b/Functions/VCS_Info/VCS_INFO_set-patch-format @@ -3,8 +3,10 @@ # # Parameters: # $1 - name of an array parameter to be the argument to gen-applied-string +# (patches in reverse order) # $2 - name of a parameter to store the applied-string in # $3 - name of an array parameter to be the argument to gen-unapplied-string +# (patches in order) # $4 - name of a parameter to store the unapplied-string in # $5 - context argument for use in zstyle getters # $6 - name of a parameter to store a patch-format format string in diff --git a/Functions/Zle/edit-command-line b/Functions/Zle/edit-command-line index e17893e93..991775ea5 100644 --- a/Functions/Zle/edit-command-line +++ b/Functions/Zle/edit-command-line @@ -6,6 +6,8 @@ # will give ksh-like behaviour for that key, # except that it will handle multi-line buffers properly. +emulate -L zsh + () { exec </dev/tty diff --git a/Functions/Zle/select-bracketed b/Functions/Zle/select-bracketed index d467bb804..0cb4d0e76 100644 --- a/Functions/Zle/select-bracketed +++ b/Functions/Zle/select-bracketed @@ -17,8 +17,8 @@ setopt localoptions noksharrays local style=${${1:-$KEYS}[1]} matching="(){}[]<>bbBB" local -i find=${NUMERIC:-1} idx=${matching[(I)[${${1:-$KEYS}[2]}]]}%9 (( idx )) || return 1 # no corresponding closing bracket -local lmatch=${matching[1 + (idx-1) & ~1]} -local rmatch=${matching[1 + (idx-1) | 1]} +local lmatch=${matching[1 + ((idx-1) & ~1)]} +local rmatch=${matching[1 + ((idx-1) | 1)]} local -i start=CURSOR+1 end=CURSOR+1 rfind=find [[ $BUFFER[start] = "$rmatch" ]] && (( start--, end-- )) |