1
0
Fork 0
mirror of git://git.code.sf.net/p/zsh/code synced 2025-10-27 04:40:59 +01:00

40403/0001: vcs_info set-patch-format helper: Part #1.

This commit is contained in:
Daniel Shahaf 2017-01-23 18:15:35 +00:00
parent 57013f8b96
commit 0ea1957608
6 changed files with 31 additions and 28 deletions

View file

@ -125,16 +125,7 @@ VCS_INFO_git_handle_patches () {
git_patches_unapplied=(${(Oa)git_patches_unapplied})
(( git_all = ${#git_patches_applied} + ${#git_patches_unapplied} ))
if VCS_INFO_hook 'gen-applied-string' "${git_patches_applied[@]}"; then
if (( ${#git_patches_applied} )); then
git_applied_s=${git_patches_applied[1]}
else
git_applied_s=""
fi
else
git_applied_s=${hook_com[applied-string]}
fi
hook_com=()
VCS_INFO_set-patch-format 'git_patches_applied' 'git_applied_s'
if VCS_INFO_hook 'gen-unapplied-string' "${git_patches_unapplied[@]}"; then
git_unapplied_s=${#git_patches_unapplied}
else

View file

@ -203,14 +203,7 @@ if zstyle -T ":vcs_info:${vcs}:${usercontext}:${rrn}" get-mq \
done < ${mqseriesfile}
fi
if VCS_INFO_hook 'gen-applied-string' "${mqpatches[@]}"; then
(( ${#mqpatches} )) && applied_string=${mqpatches[1]}
else
applied_string=${hook_com[applied-string]}
fi
hook_com=()
VCS_INFO_set-patch-format 'mqpatches' 'applied_string'
if VCS_INFO_hook 'gen-unapplied-string' "${mqunapplied[@]}"; then
unapplied_string=${#mqunapplied}
else

View file

@ -173,16 +173,7 @@ function VCS_INFO_quilt() {
all=( ${(Oa)applied} ${unapplied} )
if VCS_INFO_hook 'gen-applied-string' "${applied[@]}"; then
if (( ${#applied} )); then
applied_string=${applied[1]}
else
applied_string=""
fi
else
applied_string=${hook_com[applied-string]}
fi
hook_com=()
VCS_INFO_set-patch-format 'applied' 'applied_string'
if VCS_INFO_hook 'gen-unapplied-string' "${unapplied[@]}"; then
unapplied_string="${#unapplied}"
else

View file

@ -0,0 +1,20 @@
# This function is the common guts of the gen-applied-string /
# gen-unapplied-string / set-patch-format dance of several backends.
#
# Parameters:
# $1 - name of an array parameter to be the argument to gen-applied-string
# $2 - name of a parameter to store the applied-string in
{
local REPLY
if VCS_INFO_hook 'gen-applied-string' "${(@P)1}"; then
if (( ${(P)#1} )); then
REPLY=${(P)1[1]}
else
REPLY=""
fi
else
REPLY=${hook_com[applied-string]}
fi
: ${(P)2::=$REPLY}
hook_com=()
}

View file

@ -21,6 +21,7 @@ static_functions=(
VCS_INFO_get_cmd
VCS_INFO_hexdump
VCS_INFO_hook
VCS_INFO_set-patch-format
VCS_INFO_maxexports
VCS_INFO_nvcsformats
VCS_INFO_patch2subject