From 5448e1611d2cc4cb436fedfc3e7ff0f1ebfc766b Mon Sep 17 00:00:00 2001 From: Daniel Shahaf Date: Sat, 8 Aug 2020 07:29:34 +0000 Subject: 47303: vcs_info hg: Fix changing the expansion of %g (hook_com[guards]) in the set-patch-format hook (regression from workers/40480). 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/VCS_INFO_set-patch-format | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (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 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]} -- cgit v1.2.3 From c055c6464de20da13a6c805f017543f94b6e0ca9 Mon Sep 17 00:00:00 2001 From: Daniel Shahaf Date: Sat, 29 Jan 2022 11:08:21 +0000 Subject: unposted: vcs_info: Add Vim modelines ... for consistency with all other vcs_info function files. --- ChangeLog | 5 +++++ Functions/VCS_Info/VCS_INFO_patch2subject | 2 ++ Functions/VCS_Info/VCS_INFO_set-branch-format | 2 ++ Functions/VCS_Info/VCS_INFO_set-patch-format | 2 ++ Misc/vcs_info-examples | 2 ++ 5 files changed, 13 insertions(+) (limited to 'Functions/VCS_Info/VCS_INFO_set-patch-format') diff --git a/ChangeLog b/ChangeLog index 1aa704c23..92646df79 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,10 @@ 2022-01-29 Daniel Shahaf + * unposted: Functions/VCS_Info/VCS_INFO_patch2subject, + Functions/VCS_Info/VCS_INFO_set-branch-format, + Functions/VCS_Info/VCS_INFO_set-patch-format: vcs_info: Add + Vim modelines + * 49723: Functions/VCS_Info/VCS_INFO_quilt: vcs_info quilt: Use quilt-patch-dir and ${QUILT_PATCHES} even when get-unapplied hasn't been set diff --git a/Functions/VCS_Info/VCS_INFO_patch2subject b/Functions/VCS_Info/VCS_INFO_patch2subject index a467edcdb..5aa9efd23 100644 --- a/Functions/VCS_Info/VCS_INFO_patch2subject +++ b/Functions/VCS_Info/VCS_INFO_patch2subject @@ -1,3 +1,5 @@ +## vim:ft=zsh +# # This function takes as an argument a filename of a patch and sets $REPLY to # a single-line "subject", or unsets it if no subject could be extracted. { diff --git a/Functions/VCS_Info/VCS_INFO_set-branch-format b/Functions/VCS_Info/VCS_INFO_set-branch-format index 8cff51b9a..cbab60e29 100644 --- a/Functions/VCS_Info/VCS_INFO_set-branch-format +++ b/Functions/VCS_Info/VCS_INFO_set-branch-format @@ -1,3 +1,5 @@ +## vim:ft=zsh +# # A function for calling the branch-format hook # # Return the value to use in REPLY diff --git a/Functions/VCS_Info/VCS_INFO_set-patch-format b/Functions/VCS_Info/VCS_INFO_set-patch-format index e387110a2..c35b695c3 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. # diff --git a/Misc/vcs_info-examples b/Misc/vcs_info-examples index c2b02a2ac..94c47278d 100644 --- a/Misc/vcs_info-examples +++ b/Misc/vcs_info-examples @@ -1,3 +1,5 @@ +## vim:ft=zsh +# # A collection of vcs_info usage examples ### Running vcs_info ######################################################### -- cgit v1.2.3 From 80389df48067bab3711ad1604bc9554d08fb9994 Mon Sep 17 00:00:00 2001 From: Daniel Shahaf Date: Sat, 29 Jan 2022 16:15:25 +0000 Subject: 49727 (+ comment): vcs_info quilt: Pass the patches dir path to the gen-applied-string, gen-unapplied-string, and set-patch-format hooks I use that in my gen-applied-string hook. --- ChangeLog | 8 ++++++++ Doc/Zsh/contrib.yo | 15 +++++++++++++++ Functions/VCS_Info/Backends/VCS_INFO_get_data_git | 2 +- Functions/VCS_Info/Backends/VCS_INFO_get_data_hg | 2 +- Functions/VCS_Info/VCS_INFO_quilt | 7 ++++++- Functions/VCS_Info/VCS_INFO_set-patch-format | 8 +++++++- 6 files changed, 38 insertions(+), 4 deletions(-) (limited to 'Functions/VCS_Info/VCS_INFO_set-patch-format') diff --git a/ChangeLog b/ChangeLog index 6576ec634..a856cc47f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,13 @@ 2022-02-20 Daniel Shahaf + * 49727 (+ comment): Doc/Zsh/contrib.yo, + Functions/VCS_Info/Backends/VCS_INFO_get_data_git, + Functions/VCS_Info/Backends/VCS_INFO_get_data_hg, + Functions/VCS_Info/VCS_INFO_quilt, + Functions/VCS_Info/VCS_INFO_set-patch-format: vcs_info + quilt: Pass the patches dir path to the gen-applied-string, + gen-unapplied-string, and set-patch-format hooks + * unposted: Functions/VCS_Info/Backends/VCS_INFO_get_data_hg: vcs_info hg mg (with get-unapplied set): Stop leaking a variable to global scope diff --git a/Doc/Zsh/contrib.yo b/Doc/Zsh/contrib.yo index eb5bbafb2..0adef7334 100644 --- a/Doc/Zsh/contrib.yo +++ b/Doc/Zsh/contrib.yo @@ -1669,6 +1669,11 @@ available as tt(%p) in the tt(patch-format) and tt(nopatch-format) styles. This hook is, in concert with tt(set-patch-format), responsible for tt(%)-escaping that value for use in the prompt. (See ifzman(the bf(Oddities) section)ifnzman(noderef(vcs_info Oddities)).) + +COMMENT(This paragraph is repeated above/below)\ +The tt(quilt) backend passes to this hook the inputs +tt(${hook_com[quilt-patches-dir]}) and, if it has been +determined, tt(${hook_com[quilt-pc-dir]}). ) item(tt(gen-unapplied-string))( Called in the tt(git) (with tt(stgit) or during rebase), and tt(hg) (with @@ -1687,6 +1692,11 @@ tt(patch-format) and tt(nopatch-format) styles. This hook is, in concert with tt(set-patch-format), responsible for tt(%)-escaping that value for use in the prompt. (See ifzman(the bf(Oddities) section)ifnzman(noderef(vcs_info Oddities)).) + +COMMENT(This paragraph is repeated above/below)\ +The tt(quilt) backend passes to this hook the inputs +tt(${hook_com[quilt-patches-dir]}) and, if it has been +determined, tt(${hook_com[quilt-pc-dir]}). ) item(tt(gen-mqguards-string))( Called in the tt(hg) backend when tt(guards-string) is generated; the @@ -1769,6 +1779,11 @@ This hook is, in concert with the tt(gen-applied-string) or tt(gen-unapplied-string) hooks if they are defined, responsible for tt(%)-escaping the final tt(patch-format) value for use in the prompt. (See ifzman(the bf(Oddities) section)ifnzman(noderef(vcs_info Oddities)).) + +COMMENT(This paragraph is repeated above/below)\ +The tt(quilt) backend passes to this hook the inputs +tt(${hook_com[quilt-patches-dir]}) and, if it has been +determined, tt(${hook_com[quilt-pc-dir]}). ) item(tt(set-message))( Called each time before a `tt(vcs_info_msg_)var(N)tt(_)' message is set. diff --git a/Functions/VCS_Info/Backends/VCS_INFO_get_data_git b/Functions/VCS_Info/Backends/VCS_INFO_get_data_git index fe084dffb..e45eebc8e 100644 --- a/Functions/VCS_Info/Backends/VCS_INFO_get_data_git +++ b/Functions/VCS_Info/Backends/VCS_INFO_get_data_git @@ -132,7 +132,7 @@ VCS_INFO_git_handle_patches () { VCS_INFO_set-patch-format 'git_patches_applied' 'git_applied_s' \ 'git_patches_unapplied' 'git_unapplied_s' \ ":vcs_info:${vcs}:${usercontext}:${rrn}" gitmsg \ - '' '' + '' '' '' gitmisc=$REPLY } diff --git a/Functions/VCS_Info/Backends/VCS_INFO_get_data_hg b/Functions/VCS_Info/Backends/VCS_INFO_get_data_hg index 97086670c..e7123f0bf 100644 --- a/Functions/VCS_Info/Backends/VCS_INFO_get_data_hg +++ b/Functions/VCS_Info/Backends/VCS_INFO_get_data_hg @@ -225,7 +225,7 @@ if zstyle -T ":vcs_info:${vcs}:${usercontext}:${rrn}" get-mq \ VCS_INFO_set-patch-format 'mqpatches' 'applied_string' \ 'mqunapplied' 'unapplied_string' \ ":vcs_info:${vcs}:${usercontext}:${rrn}" hgmqstring \ - extra_hook_com VCS_INFO_hg_extra_zformats + extra_hook_com VCS_INFO_hg_extra_zformats '' hgmqstring=$REPLY fi diff --git a/Functions/VCS_Info/VCS_INFO_quilt b/Functions/VCS_Info/VCS_INFO_quilt index ee242f552..ce5b41f24 100644 --- a/Functions/VCS_Info/VCS_INFO_quilt +++ b/Functions/VCS_Info/VCS_INFO_quilt @@ -179,10 +179,15 @@ function VCS_INFO_quilt-patch2subject() { done } + typeset -A quilt_extra_info=( + quilt-patches-dir ${patches} + ${pc:+"quilt-pc-dir"} $pc + ) + VCS_INFO_set-patch-format 'applied' 'applied_string' \ 'unapplied' 'unapplied_string' \ ${context} qstring \ - '' '' + quilt_extra_info '' quilt_extra_info qstring=$REPLY case ${mode} in diff --git a/Functions/VCS_Info/VCS_INFO_set-patch-format b/Functions/VCS_Info/VCS_INFO_set-patch-format index c35b695c3..1c774a7f6 100644 --- a/Functions/VCS_Info/VCS_INFO_set-patch-format +++ b/Functions/VCS_Info/VCS_INFO_set-patch-format @@ -15,6 +15,8 @@ # $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 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. # @@ -22,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]} @@ -37,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' -- cgit v1.2.3