From 33c0a104482a0299d5d065b88c180ea6975269c0 Mon Sep 17 00:00:00 2001 From: Daniel Shahaf Date: Wed, 1 Feb 2017 19:05:45 +0000 Subject: 40480: vcs_info set-patch-format: Eliminate the remaining code duplication. --- Functions/VCS_Info/VCS_INFO_set-patch-format | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'Functions/VCS_Info/VCS_INFO_set-patch-format') 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=() } -- cgit v1.2.3