summaryrefslogtreecommitdiff
path: root/Functions/VCS_Info/VCS_INFO_set-patch-format
diff options
context:
space:
mode:
authorDaniel Shahaf <d.s@daniel.shahaf.name>2017-02-01 19:05:45 +0000
committerDaniel Shahaf <d.s@daniel.shahaf.name>2017-02-03 18:14:01 +0000
commit33c0a104482a0299d5d065b88c180ea6975269c0 (patch)
treefd875fba09b03a458d424b062e661a99cab52f11 /Functions/VCS_Info/VCS_INFO_set-patch-format
parent9211d7f2777abaedfacf98812104d579c3b861f3 (diff)
downloadzsh-33c0a104482a0299d5d065b88c180ea6975269c0.tar.gz
zsh-33c0a104482a0299d5d065b88c180ea6975269c0.zip
40480: vcs_info set-patch-format: Eliminate the remaining code duplication.
Diffstat (limited to 'Functions/VCS_Info/VCS_INFO_set-patch-format')
-rw-r--r--Functions/VCS_Info/VCS_INFO_set-patch-format13
1 files changed, 12 insertions, 1 deletions
diff --git a/Functions/VCS_Info/VCS_INFO_set-patch-format b/Functions/VCS_Info/VCS_INFO_set-patch-format
index 5534e4832..c5da36808 100644
--- a/Functions/VCS_Info/VCS_INFO_set-patch-format
+++ b/Functions/VCS_Info/VCS_INFO_set-patch-format
@@ -10,12 +10,14 @@
# $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
+#
+# The expanded patch-format string is returned in $REPLY.
#
# Output:
# - $hook_com is overwritten and the keys 'applied', 'applied-n',
# 'unapplied', 'unapplied-n', 'all-n' are set.
{
- local REPLY
if VCS_INFO_hook 'gen-applied-string' "${(@P)1}"; then
if (( ${(P)#1} )); then
REPLY=${(P)1[1]}
@@ -51,4 +53,13 @@
)
hook_com[all-n]=$(( ${hook_com[applied-n]} + ${hook_com[unapplied-n]} ))
hook_com+=( ${7:+"${(@kvP)7}"} )
+ if VCS_INFO_hook 'set-patch-format' "${(P)6}"; then
+ 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}"}
+ else
+ REPLY=${hook_com[patch-replace]}
+ fi
+ hook_com=()
}