zsh-workers
 help / color / mirror / code / Atom feed
From: Daniel Shahaf <d.s@daniel.shahaf.name>
To: zsh-workers@zsh.org
Subject: [PATCH] vcs_info hg: Fix changing the expansion of %g (hook_com[guards]) in the set-patch-format hook (regression from workers/40480).
Date: Sat,  8 Aug 2020 07:29:34 +0000	[thread overview]
Message-ID: <20200808072934.30137-1-danielsh@tarpaulin.shahaf.local2> (raw)

To reproduce, go to a hg repository with active mq guards and configure
vcs_info as follows:

    zstyle '*' get-unapplied true
    zstyle ':vcs_info:*set-patch-format*' hooks f
    zstyle '*' patch-format '[%g : %G]'
    zstyle '*' nopatch-format '[%g : %G]'
    zstyle '*' formats '%m'
    +vi-f () {
    	hook_com[guards]+=XXX
    }

The regression was first released in 5.3.1-test-2, over three years ago.
---
 Functions/VCS_Info/Backends/VCS_INFO_get_data_hg | 8 ++++++--
 Functions/VCS_Info/VCS_INFO_set-patch-format     | 6 ++++--
 2 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/Functions/VCS_Info/Backends/VCS_INFO_get_data_hg b/Functions/VCS_Info/Backends/VCS_INFO_get_data_hg
index 9f61aeaf4..f7e9d6f45 100644
--- a/Functions/VCS_Info/Backends/VCS_INFO_get_data_hg
+++ b/Functions/VCS_Info/Backends/VCS_INFO_get_data_hg
@@ -217,12 +217,16 @@ if zstyle -T ":vcs_info:${vcs}:${usercontext}:${rrn}" get-mq \
     fi
 
     local -A extra_hook_com=( guards "${guards_string}"   guards-n ${#mqguards} )
-    local -a extra_zformats=( "g:${extra_hook_com[guards]}" "G:${#mqguards}" )
+
+    (( ${+functions[VCS_INFO_hg_extra_zformats]} )) || 
+    VCS_INFO_hg_extra_zformats() {
+        reply=( "g:${hook_com[guards]}" "G:${#mqguards}" )
+    }
 
     VCS_INFO_set-patch-format 'mqpatches' 'applied_string' \
                               'mqunapplied' 'unapplied_string' \
                               ":vcs_info:${vcs}:${usercontext}:${rrn}" hgmqstring \
-                              extra_hook_com extra_zformats
+                              extra_hook_com VCS_INFO_hg_extra_zformats
     hgmqstring=$REPLY
 fi
 
diff --git a/Functions/VCS_Info/VCS_INFO_set-patch-format b/Functions/VCS_Info/VCS_INFO_set-patch-format
index 917ebf6bf..e387110a2 100644
--- a/Functions/VCS_Info/VCS_INFO_set-patch-format
+++ b/Functions/VCS_Info/VCS_INFO_set-patch-format
@@ -12,7 +12,7 @@
 # $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
 #
 # The expanded patch-format string is returned in $REPLY.
 #
@@ -68,10 +68,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]}


                 reply	other threads:[~2020-08-08  7:37 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200808072934.30137-1-danielsh@tarpaulin.shahaf.local2 \
    --to=d.s@daniel.shahaf.name \
    --cc=zsh-workers@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).