summaryrefslogtreecommitdiff
path: root/Functions/VCS_Info/VCS_INFO_set-patch-format
diff options
context:
space:
mode:
authorAxel Beckert <abe@deuxchevaux.org>2022-04-11 00:17:48 +0200
committerAxel Beckert <abe@deuxchevaux.org>2022-04-11 00:17:48 +0200
commitb09f4483416c54c1782824633dfabaf2ec0265b6 (patch)
tree304bc82642862525ae680c7fbaa249663b10ad57 /Functions/VCS_Info/VCS_INFO_set-patch-format
parent12eb3e5356f2fc3351eed58ef1cef1b8fb83b504 (diff)
parent6e55c920503071e917619b8cb1a188cd35d772db (diff)
downloadzsh-b09f4483416c54c1782824633dfabaf2ec0265b6.tar.gz
zsh-b09f4483416c54c1782824633dfabaf2ec0265b6.zip
New upstream version 5.8.1.2-test
Diffstat (limited to 'Functions/VCS_Info/VCS_INFO_set-patch-format')
-rw-r--r--Functions/VCS_Info/VCS_INFO_set-patch-format16
1 files changed, 13 insertions, 3 deletions
diff --git a/Functions/VCS_Info/VCS_INFO_set-patch-format b/Functions/VCS_Info/VCS_INFO_set-patch-format
index 917ebf6bf..1c774a7f6 100644
--- a/Functions/VCS_Info/VCS_INFO_set-patch-format
+++ b/Functions/VCS_Info/VCS_INFO_set-patch-format
@@ -1,3 +1,5 @@
+## vim:ft=zsh
+#
# This function is the common guts of the gen-applied-string /
# gen-unapplied-string / set-patch-format dance of several backends.
#
@@ -12,7 +14,9 @@
# $6 - name of a parameter to store a patch-format format string in
# $7 - name of an assoc parameter with extra $hook_com key-value pairs for the
# set-patch-format hook invocation, or '' for none
-# $8 - name of an array parameter with extra arguments for the patch-format zformat call, or '' for empty
+# $8 - name of a function that sets $reply to extra arguments for the patch-format zformat call, or '' for none
+# $9 - name of an assoc parameter with extra $hook_com key-value pairs for the
+# gen-applied-string & gen-unapplied-string hook invocations, or '' for none
#
# The expanded patch-format string is returned in $REPLY.
#
@@ -20,8 +24,10 @@
# - $hook_com is overwritten and the keys 'applied', 'applied-n',
# 'unapplied', 'unapplied-n', 'all-n' are set.
{
+ hook_com=()
+
local applied_needs_escaping='unknown'
- local unapplied_needs_escaping='unknown'
+ hook_com+=( ${9:+"${(@kvP)9}"} )
if VCS_INFO_hook 'gen-applied-string' "${(@P)1}"; then
if (( ${(P)#1} )); then
REPLY=${(P)1[1]}
@@ -35,6 +41,8 @@
: ${(P)2::=$REPLY}
hook_com=()
+ local unapplied_needs_escaping='unknown'
+ hook_com+=( ${9:+"${(@kvP)9}"} )
if VCS_INFO_hook 'gen-unapplied-string' "${(@P)3}"; then
REPLY=${(P)#3}
unapplied_needs_escaping='yes'
@@ -68,10 +76,12 @@
hook_com[unapplied]=${hook_com[unapplied]//'%'/%%}
fi
+ reply=()
+ [[ -n $8 ]] && "$8"
zformat -f REPLY "${(P)6}" "p:${hook_com[applied]}" "u:${hook_com[unapplied]}" \
"n:${hook_com[applied-n]}" "c:${hook_com[unapplied-n]}" \
"a:${hook_com[all-n]}" \
- ${8:+"${(@P)8}"}
+ "${reply[@]}"
else
unset applied_needs_escaping unapplied_needs_escaping # the hook deals with escaping
REPLY=${hook_com[patch-replace]}