Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

[PATCH 1..4/4] vcs_info set-patch-format helper



This is just a bit of code deduplication.  It depends on the %c patch
I just posted, but is independent of the "'%' in payloads not escaped"
thread.

The fourth patch also fixes a bug in the hg backend.

Will commit with ${XSEQ}/000{1..4} as before.

Cheers,

Daniel
From 6505e0aaecaccfb36804623d89c572cc5324cd0a Mon Sep 17 00:00:00 2001
From: Daniel Shahaf <d.s@xxxxxxxxxxxxxxxxxx>
Date: Mon, 23 Jan 2017 18:15:35 +0000
Subject: [PATCH 1/4] vcs_info set-patch-format helper: Part #1.

---
 Functions/VCS_Info/Backends/VCS_INFO_get_data_git | 11 +----------
 Functions/VCS_Info/Backends/VCS_INFO_get_data_hg  |  9 +--------
 Functions/VCS_Info/VCS_INFO_quilt                 | 11 +----------
 Functions/VCS_Info/VCS_INFO_set-patch-format      | 20 ++++++++++++++++++++
 Functions/VCS_Info/vcs_info                       |  1 +
 5 files changed, 24 insertions(+), 28 deletions(-)
 create mode 100644 Functions/VCS_Info/VCS_INFO_set-patch-format

diff --git a/Functions/VCS_Info/Backends/VCS_INFO_get_data_git b/Functions/VCS_Info/Backends/VCS_INFO_get_data_git
index efb77b7..02ea402 100644
--- a/Functions/VCS_Info/Backends/VCS_INFO_get_data_git
+++ b/Functions/VCS_Info/Backends/VCS_INFO_get_data_git
@@ -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
diff --git a/Functions/VCS_Info/Backends/VCS_INFO_get_data_hg b/Functions/VCS_Info/Backends/VCS_INFO_get_data_hg
index 69b7db3..19bec7a 100644
--- a/Functions/VCS_Info/Backends/VCS_INFO_get_data_hg
+++ b/Functions/VCS_Info/Backends/VCS_INFO_get_data_hg
@@ -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
diff --git a/Functions/VCS_Info/VCS_INFO_quilt b/Functions/VCS_Info/VCS_INFO_quilt
index 4c61506..dd3f495 100644
--- a/Functions/VCS_Info/VCS_INFO_quilt
+++ b/Functions/VCS_Info/VCS_INFO_quilt
@@ -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
diff --git a/Functions/VCS_Info/VCS_INFO_set-patch-format b/Functions/VCS_Info/VCS_INFO_set-patch-format
new file mode 100644
index 0000000..310df96
--- /dev/null
+++ b/Functions/VCS_Info/VCS_INFO_set-patch-format
@@ -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=()
+}
diff --git a/Functions/VCS_Info/vcs_info b/Functions/VCS_Info/vcs_info
index 24ae98e..4e9ac6c 100644
--- a/Functions/VCS_Info/vcs_info
+++ b/Functions/VCS_Info/vcs_info
@@ -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
From b9d9499e64207c780a6ad9e7adf9129b47338ea2 Mon Sep 17 00:00:00 2001
From: Daniel Shahaf <d.s@xxxxxxxxxxxxxxxxxx>
Date: Mon, 23 Jan 2017 18:15:35 +0000
Subject: [PATCH 2/4] vcs_info set-patch-format helper: Part #2.

Not all callers reset ${hook_com}, but those that don't, immediately
overwrite it a few lines later.
---
 Functions/VCS_Info/Backends/VCS_INFO_get_data_git |  8 ++------
 Functions/VCS_Info/Backends/VCS_INFO_get_data_hg  | 11 ++---------
 Functions/VCS_Info/VCS_INFO_quilt                 |  8 ++------
 Functions/VCS_Info/VCS_INFO_set-patch-format      | 10 ++++++++++
 4 files changed, 16 insertions(+), 21 deletions(-)

diff --git a/Functions/VCS_Info/Backends/VCS_INFO_get_data_git b/Functions/VCS_Info/Backends/VCS_INFO_get_data_git
index 02ea402..e7b9ac4 100644
--- a/Functions/VCS_Info/Backends/VCS_INFO_get_data_git
+++ b/Functions/VCS_Info/Backends/VCS_INFO_get_data_git
@@ -125,12 +125,8 @@ VCS_INFO_git_handle_patches () {
     git_patches_unapplied=(${(Oa)git_patches_unapplied})
     (( git_all = ${#git_patches_applied} + ${#git_patches_unapplied} ))
 
-    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
-        git_unapplied_s=${hook_com[unapplied-string]}
-    fi
+    VCS_INFO_set-patch-format 'git_patches_applied' 'git_applied_s' \
+                              'git_patches_unapplied' 'git_unapplied_s'
 
     if (( ${#git_patches_applied} )); then
         zstyle -s ":vcs_info:${vcs}:${usercontext}:${rrn}" patch-format gitmsg || gitmsg="%p (%n applied)"
diff --git a/Functions/VCS_Info/Backends/VCS_INFO_get_data_hg b/Functions/VCS_Info/Backends/VCS_INFO_get_data_hg
index 19bec7a..90164fb 100644
--- a/Functions/VCS_Info/Backends/VCS_INFO_get_data_hg
+++ b/Functions/VCS_Info/Backends/VCS_INFO_get_data_hg
@@ -203,15 +203,8 @@ if zstyle -T ":vcs_info:${vcs}:${usercontext}:${rrn}" get-mq \
         done < ${mqseriesfile}
     fi
 
-    VCS_INFO_set-patch-format 'mqpatches' 'applied_string'
-    if VCS_INFO_hook 'gen-unapplied-string' "${mqunapplied[@]}"; then
-        unapplied_string=${#mqunapplied}
-    else
-        unapplied_string=${hook_com[unapplied-string]}
-    fi
-
-    hook_com=()
-
+    VCS_INFO_set-patch-format 'mqpatches' 'applied_string' \
+                              'mqunapplied' 'unapplied_string'
     if VCS_INFO_hook 'gen-mqguards-string' "${mqguards[@]}"; then
         guards_string=${(j:,:)mqguards}
     else
diff --git a/Functions/VCS_Info/VCS_INFO_quilt b/Functions/VCS_Info/VCS_INFO_quilt
index dd3f495..1872fc7 100644
--- a/Functions/VCS_Info/VCS_INFO_quilt
+++ b/Functions/VCS_Info/VCS_INFO_quilt
@@ -173,12 +173,8 @@ function VCS_INFO_quilt() {
 
     all=( ${(Oa)applied} ${unapplied} )
 
-    VCS_INFO_set-patch-format 'applied' 'applied_string' 
-    if VCS_INFO_hook 'gen-unapplied-string' "${unapplied[@]}"; then
-        unapplied_string="${#unapplied}"
-    else
-        unapplied_string=${hook_com[unapplied-string]}
-    fi
+    VCS_INFO_set-patch-format 'applied' 'applied_string' \
+                              'unapplied' 'unapplied_string'
 
     if (( ${#applied} )); then
         zstyle -s "${context}" patch-format qstring || qstring="%p (%n applied)"
diff --git a/Functions/VCS_Info/VCS_INFO_set-patch-format b/Functions/VCS_Info/VCS_INFO_set-patch-format
index 310df96..0bbd474 100644
--- a/Functions/VCS_Info/VCS_INFO_set-patch-format
+++ b/Functions/VCS_Info/VCS_INFO_set-patch-format
@@ -4,6 +4,8 @@
 # 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
+# $3 - name of an array parameter to be the argument to gen-unapplied-string
+# $4 - name of a parameter to store the unapplied-string in
 {
     local REPLY
     if VCS_INFO_hook 'gen-applied-string' "${(@P)1}"; then
@@ -17,4 +19,12 @@
     fi
     : ${(P)2::=$REPLY}
     hook_com=()
+
+    if VCS_INFO_hook 'gen-unapplied-string' "${(@P)3}"; then
+        REPLY=${(P)#3}
+    else
+        REPLY=${hook_com[unapplied-string]}
+    fi
+    : ${(P)4::=$REPLY}
+    hook_com=()
 }
From ddb58c59a36161fc6b59c33baeea2edbdd620ddc Mon Sep 17 00:00:00 2001
From: Daniel Shahaf <d.s@xxxxxxxxxxxxxxxxxx>
Date: Mon, 23 Jan 2017 18:15:35 +0000
Subject: [PATCH 3/4] vcs_info set-patch-format helper: Part #3.

---
 Functions/VCS_Info/Backends/VCS_INFO_get_data_git |  8 ++------
 Functions/VCS_Info/Backends/VCS_INFO_get_data_hg  | 11 ++---------
 Functions/VCS_Info/VCS_INFO_quilt                 |  8 ++------
 Functions/VCS_Info/VCS_INFO_set-patch-format      |  9 +++++++++
 4 files changed, 15 insertions(+), 21 deletions(-)

diff --git a/Functions/VCS_Info/Backends/VCS_INFO_get_data_git b/Functions/VCS_Info/Backends/VCS_INFO_get_data_git
index e7b9ac4..b44f00c 100644
--- a/Functions/VCS_Info/Backends/VCS_INFO_get_data_git
+++ b/Functions/VCS_Info/Backends/VCS_INFO_get_data_git
@@ -126,13 +126,9 @@ VCS_INFO_git_handle_patches () {
     (( git_all = ${#git_patches_applied} + ${#git_patches_unapplied} ))
 
     VCS_INFO_set-patch-format 'git_patches_applied' 'git_applied_s' \
-                              'git_patches_unapplied' 'git_unapplied_s'
+                              'git_patches_unapplied' 'git_unapplied_s' \
+                              ":vcs_info:${vcs}:${usercontext}:${rrn}" gitmsg
 
-    if (( ${#git_patches_applied} )); then
-        zstyle -s ":vcs_info:${vcs}:${usercontext}:${rrn}" patch-format gitmsg || gitmsg="%p (%n applied)"
-    else
-        zstyle -s ":vcs_info:${vcs}:${usercontext}:${rrn}" nopatch-format gitmsg || gitmsg="no patch applied"
-    fi
     hook_com=( applied "${git_applied_s}"     unapplied "${git_unapplied_s}"
                applied-n ${#git_patches_applied} unapplied-n ${#git_patches_unapplied} all-n ${git_all} )
     if VCS_INFO_hook 'set-patch-format' "${gitmsg}"; then
diff --git a/Functions/VCS_Info/Backends/VCS_INFO_get_data_hg b/Functions/VCS_Info/Backends/VCS_INFO_get_data_hg
index 90164fb..52effa5 100644
--- a/Functions/VCS_Info/Backends/VCS_INFO_get_data_hg
+++ b/Functions/VCS_Info/Backends/VCS_INFO_get_data_hg
@@ -204,21 +204,14 @@ if zstyle -T ":vcs_info:${vcs}:${usercontext}:${rrn}" get-mq \
     fi
 
     VCS_INFO_set-patch-format 'mqpatches' 'applied_string' \
-                              'mqunapplied' 'unapplied_string'
+                              'mqunapplied' 'unapplied_string' \
+                              ":vcs_info:${vcs}:${usercontext}:${rrn}" hgmqstring
     if VCS_INFO_hook 'gen-mqguards-string' "${mqguards[@]}"; then
         guards_string=${(j:,:)mqguards}
     else
         guards_string=${hook_com[guards-string]}
     fi
 
-    if (( ${#mqpatches} )); then
-        zstyle -s ":vcs_info:${vcs}:${usercontext}:${rrn}" patch-format \
-            hgmqstring || hgmqstring="%p (%n applied)"
-    else
-        zstyle -s ":vcs_info:${vcs}:${usercontext}:${rrn}" nopatch-format \
-            hgmqstring || hgmqstring="no patch applied"
-    fi
-
     hook_com=( applied "${applied_string}" unapplied "${unapplied_string}"
                applied-n ${#mqpatches}     unapplied-n ${#mqunapplied}     all-n ${#mqseries}
                guards "${guards_string}"   guards-n ${#mqguards} )
diff --git a/Functions/VCS_Info/VCS_INFO_quilt b/Functions/VCS_Info/VCS_INFO_quilt
index 1872fc7..a81da1c 100644
--- a/Functions/VCS_Info/VCS_INFO_quilt
+++ b/Functions/VCS_Info/VCS_INFO_quilt
@@ -174,13 +174,9 @@ function VCS_INFO_quilt() {
     all=( ${(Oa)applied} ${unapplied} )
 
     VCS_INFO_set-patch-format 'applied' 'applied_string' \
-                              'unapplied' 'unapplied_string'
+                              'unapplied' 'unapplied_string' \
+                              ${context} qstring
 
-    if (( ${#applied} )); then
-        zstyle -s "${context}" patch-format qstring || qstring="%p (%n applied)"
-    else
-        zstyle -s "${context}" nopatch-format qstring || qstring="no patch applied"
-    fi
     hook_com=( applied "${applied_string}" unapplied "${unapplied_string}"
                applied-n ${#applied}       unapplied-n ${#unapplied}       all-n ${#all} )
     if VCS_INFO_hook 'set-patch-format' ${qstring}; then
diff --git a/Functions/VCS_Info/VCS_INFO_set-patch-format b/Functions/VCS_Info/VCS_INFO_set-patch-format
index 0bbd474..664b456 100644
--- a/Functions/VCS_Info/VCS_INFO_set-patch-format
+++ b/Functions/VCS_Info/VCS_INFO_set-patch-format
@@ -6,6 +6,8 @@
 # $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
 # $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
 {
     local REPLY
     if VCS_INFO_hook 'gen-applied-string' "${(@P)1}"; then
@@ -27,4 +29,11 @@
     fi
     : ${(P)4::=$REPLY}
     hook_com=()
+
+    if (( ${(P)#1} )); then
+        zstyle -s "${5}" patch-format REPLY || REPLY="%p (%n applied)"
+    else
+        zstyle -s "${5}" nopatch-format REPLY || REPLY="no patch applied"
+    fi
+    : ${(P)6::=$REPLY}
 }
From c6a8845d370658cf4fcf79ab7e40ddf2bbd1b526 Mon Sep 17 00:00:00 2001
From: Daniel Shahaf <d.s@xxxxxxxxxxxxxxxxxx>
Date: Mon, 23 Jan 2017 18:15:35 +0000
Subject: [PATCH 4/4] vcs_info set-patch-format helper: Part #4.

This also fixes the %a (${hook_com[all-n]}) expando in the hg backend:
before this change, it counted only unapplied changes.
---
 Functions/VCS_Info/Backends/VCS_INFO_get_data_git |  8 +++-----
 Functions/VCS_Info/Backends/VCS_INFO_get_data_hg  | 11 +++--------
 Functions/VCS_Info/VCS_INFO_quilt                 |  9 ++-------
 Functions/VCS_Info/VCS_INFO_set-patch-format      | 12 ++++++++++++
 4 files changed, 20 insertions(+), 20 deletions(-)

diff --git a/Functions/VCS_Info/Backends/VCS_INFO_get_data_git b/Functions/VCS_Info/Backends/VCS_INFO_get_data_git
index b44f00c..c4ae3fa 100644
--- a/Functions/VCS_Info/Backends/VCS_INFO_get_data_git
+++ b/Functions/VCS_Info/Backends/VCS_INFO_get_data_git
@@ -120,20 +120,18 @@ VCS_INFO_git_getbranch () {
 }
 
 VCS_INFO_git_handle_patches () {
-    local git_applied_s git_unapplied_s gitmsg git_all
+    local git_applied_s git_unapplied_s gitmsg
     git_patches_applied=(${(Oa)git_patches_applied})
     git_patches_unapplied=(${(Oa)git_patches_unapplied})
-    (( git_all = ${#git_patches_applied} + ${#git_patches_unapplied} ))
 
     VCS_INFO_set-patch-format 'git_patches_applied' 'git_applied_s' \
                               'git_patches_unapplied' 'git_unapplied_s' \
                               ":vcs_info:${vcs}:${usercontext}:${rrn}" gitmsg
 
-    hook_com=( applied "${git_applied_s}"     unapplied "${git_unapplied_s}"
-               applied-n ${#git_patches_applied} unapplied-n ${#git_patches_unapplied} all-n ${git_all} )
     if VCS_INFO_hook 'set-patch-format' "${gitmsg}"; then
         zformat -f gitmisc "${gitmsg}" "p:${hook_com[applied]}" "u:${hook_com[unapplied]}" \
-                                          "n:${#git_patches_applied}" "c:${#git_patches_unapplied}" "a:${git_all}"
+                                          "n:${#git_patches_applied}" "c:${#git_patches_unapplied}" \
+                                          "a:${hook_com[all-n]}"
     else
         gitmisc=${hook_com[patch-replace]}
     fi
diff --git a/Functions/VCS_Info/Backends/VCS_INFO_get_data_hg b/Functions/VCS_Info/Backends/VCS_INFO_get_data_hg
index 52effa5..c99452e 100644
--- a/Functions/VCS_Info/Backends/VCS_INFO_get_data_hg
+++ b/Functions/VCS_Info/Backends/VCS_INFO_get_data_hg
@@ -13,7 +13,7 @@ local hgbase bmfile branchfile rebasefile dirstatefile mqseriesfile \
     hgbmstring hgmqstring applied_string unapplied_string guards_string
 
 local -a hgid_args defrevformat defbranchformat \
-    hgbmarks mqpatches mqseries mqguards mqunapplied hgmisc \
+    hgbmarks mqpatches mqguards mqunapplied hgmisc \
     i_patchguards i_negguards i_posguards
 
 local -A hook_com
@@ -175,9 +175,6 @@ if zstyle -T ":vcs_info:${vcs}:${usercontext}:${rrn}" get-mq \
             # Skip commented lines
             [[ ${i_patch} == [[:space:]]#"#"* ]] && continue
 
-            # Keep list of all patches
-            mqseries+=( $i_patch )
-
             # Separate negative and positive guards to more easily find the
             # intersection of active guards with patch guards
             i_patchguards=( ${(s: :)i_patchguards} )
@@ -212,14 +209,12 @@ if zstyle -T ":vcs_info:${vcs}:${usercontext}:${rrn}" get-mq \
         guards_string=${hook_com[guards-string]}
     fi
 
-    hook_com=( applied "${applied_string}" unapplied "${unapplied_string}"
-               applied-n ${#mqpatches}     unapplied-n ${#mqunapplied}     all-n ${#mqseries}
-               guards "${guards_string}"   guards-n ${#mqguards} )
+    hook_com+=( guards "${guards_string}"   guards-n ${#mqguards} )
 
     if VCS_INFO_hook 'set-patch-format' ${qstring}; then
         zformat -f hgmqstring "${hgmqstring}" \
             "p:${hook_com[applied]}" "u:${hook_com[unapplied]}" \
-            "n:${#mqpatches}" "c:${#mqunapplied}" "a:${#mqseries}" \
+            "n:${#mqpatches}" "c:${#mqunapplied}" "a:${hook_com[all-n]}" \
             "g:${hook_com[guards]}" "G:${#mqguards}"
     else
         hgmqstring=${hook_com[patch-replace]}
diff --git a/Functions/VCS_Info/VCS_INFO_quilt b/Functions/VCS_Info/VCS_INFO_quilt
index a81da1c..aed9f0c 100644
--- a/Functions/VCS_Info/VCS_INFO_quilt
+++ b/Functions/VCS_Info/VCS_INFO_quilt
@@ -91,7 +91,7 @@ function VCS_INFO_quilt() {
     local patches pc tmp qstring root
     local -i ret
     local context
-    local -a applied unapplied all applied_string unapplied_string quiltcommand quilt_env
+    local -a applied unapplied applied_string unapplied_string quiltcommand quilt_env
     local -A hook_com
 
     context=":vcs_info:${vcs}.quilt-${mode}:${usercontext}:${rrn}"
@@ -171,17 +171,12 @@ function VCS_INFO_quilt() {
       }
     fi
 
-    all=( ${(Oa)applied} ${unapplied} )
-
     VCS_INFO_set-patch-format 'applied' 'applied_string' \
                               'unapplied' 'unapplied_string' \
                               ${context} qstring
-
-    hook_com=( applied "${applied_string}" unapplied "${unapplied_string}"
-               applied-n ${#applied}       unapplied-n ${#unapplied}       all-n ${#all} )
     if VCS_INFO_hook 'set-patch-format' ${qstring}; then
         zformat -f qstring "${qstring}" "p:${hook_com[applied]}" "u:${hook_com[unapplied]}" \
-                                        "n:${#applied}" "c:${#unapplied}" "a:${#all}"
+                                        "n:${#applied}" "c:${#unapplied}" "a:${hook_com[all-n]}"
     else
         qstring=${hook_com[patch-replace]}
     fi
diff --git a/Functions/VCS_Info/VCS_INFO_set-patch-format b/Functions/VCS_Info/VCS_INFO_set-patch-format
index 664b456..84febab 100644
--- a/Functions/VCS_Info/VCS_INFO_set-patch-format
+++ b/Functions/VCS_Info/VCS_INFO_set-patch-format
@@ -8,6 +8,10 @@
 # $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
+#
+# 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
@@ -36,4 +40,12 @@
         zstyle -s "${5}" nopatch-format REPLY || REPLY="no patch applied"
     fi
     : ${(P)6::=$REPLY}
+
+    hook_com=(
+      applied-n ${(P)#1}
+      applied ${(P)2}
+      unapplied-n ${(P)#3}
+      unapplied ${(P)4}
+    )
+    hook_com[all-n]=$(( ${hook_com[applied-n]} + ${hook_com[unapplied-n]} ))
 }


Messages sorted by: Reverse Date, Date, Thread, Author