zsh-workers
 help / color / mirror / code / Atom feed
* [PATCH 1/2] vcs_info quilt: Refactor for readability. No functional change.
@ 2022-01-27 17:58 Daniel Shahaf
  2022-01-27 17:58 ` [PATCH 2/2] vcs_info quilt: Use quilt-patch-dir and ${QUILT_PATCHES} even when get-unapplied hasn't been set Daniel Shahaf
  0 siblings, 1 reply; 3+ messages in thread
From: Daniel Shahaf @ 2022-01-27 17:58 UTC (permalink / raw)
  To: zsh-workers; +Cc: Marc Finet

---
 Functions/VCS_Info/VCS_INFO_quilt | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/Functions/VCS_Info/VCS_INFO_quilt b/Functions/VCS_Info/VCS_INFO_quilt
index 06feb4cce..22212171a 100644
--- a/Functions/VCS_Info/VCS_INFO_quilt
+++ b/Functions/VCS_Info/VCS_INFO_quilt
@@ -92,7 +92,7 @@ function VCS_INFO_quilt-patch2subject() {
     emulate -L zsh
     setopt extendedglob
     local mode="$1"
-    local patches pc tmp qstring root
+    local patches pc qstring root
     local -i ret
     local context
     local -a applied unapplied applied_string unapplied_string quiltcommand quilt_env
@@ -135,12 +135,13 @@ function VCS_INFO_quilt-patch2subject() {
         zstyle -s "${context}" quiltcommand quiltcommand || quiltcommand='quilt'
         if [ -z "$patches" ]; then
             zstyle -s "${context}" quilt-patch-dir patches || patches="${QUILT_PATCHES}"
+            : ${patches:="patches"}
             if [[ "${patches}" != /* ]]; then
-                tmp=${patches:-patches}
-                VCS_INFO_quilt-dirfind "${tmp}"
-                ret=$? patches=$REPLY
-                (( ret )) && return ${ret}
-                patches=${patches}/${tmp}
+                if VCS_INFO_quilt-dirfind "${patches}"; then
+                    patches="$REPLY/${patches}"
+                else
+                    return $?
+                fi
             else
                 [[ -d ${patches} ]] || return 1
             fi


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH 2/2] vcs_info quilt: Use quilt-patch-dir and ${QUILT_PATCHES} even when get-unapplied hasn't been set
  2022-01-27 17:58 [PATCH 1/2] vcs_info quilt: Refactor for readability. No functional change Daniel Shahaf
@ 2022-01-27 17:58 ` Daniel Shahaf
  2022-01-27 18:12   ` Daniel Shahaf
  0 siblings, 1 reply; 3+ messages in thread
From: Daniel Shahaf @ 2022-01-27 17:58 UTC (permalink / raw)
  To: zsh-workers; +Cc: Marc Finet

This affects the post-quilt hook.  Before this patch, if no patches have
been applied and get-unapplied hasn't been set, the second argument to
that hook would undergo null elision.

The generation of patch subjects for the gen-applied-string,
gen-unapplied-string, and set-patch-format hooks was unaffected since
it was guarded by [[ -n $patches ]].
---
 Functions/VCS_Info/VCS_INFO_quilt | 45 ++++++++++++++++---------------
 1 file changed, 24 insertions(+), 21 deletions(-)

diff --git a/Functions/VCS_Info/VCS_INFO_quilt b/Functions/VCS_Info/VCS_INFO_quilt
index 22212171a..ee242f552 100644
--- a/Functions/VCS_Info/VCS_INFO_quilt
+++ b/Functions/VCS_Info/VCS_INFO_quilt
@@ -113,9 +113,12 @@ function VCS_INFO_quilt-patch2subject() {
         ;;
     esac
 
-    VCS_INFO_quilt-dirfind .pc .version
-    ret=$? pc=$REPLY
-    if (( ret == 0 )); then
+    # Look for the patches directory.
+    #
+    # 1. Check if there's a .pc/.version file in a parent dir.  If so, use the
+    # patches dir from the corresponding .pc/.quilt_patches.
+    if VCS_INFO_quilt-dirfind .pc .version; then
+        pc=$REPLY
         [[ ${quiltmode} == 'standalone' ]] && root=${pc}
         pc=${pc}/.pc
         if [[ -e ${pc}/applied-patches ]]; then
@@ -128,25 +131,27 @@ function VCS_INFO_quilt-patch2subject() {
         fi
         patches=$(<$pc/.quilt_patches)
         patches=`builtin cd -q "${pc:h}" && print -r - ${patches:P}`
+    # 2. Else, locate a patches dir using the style settings.
+    else
+        zstyle -s "${context}" quilt-patch-dir patches || patches="${QUILT_PATCHES}"
+        : ${patches:="patches"}
+        if [[ "${patches}" != /* ]]; then
+            if VCS_INFO_quilt-dirfind "${patches}"; then
+                patches=$REPLY/$patches
+            else
+                return $?
+            fi
+        else
+            [[ -d ${patches} ]] || return 1
+        fi
+        quilt_env+=(QUILT_PATCHES="$patches")
     fi
+    # At this point, $patches is set and points to an existing directory.
+
     if zstyle -t "${context}" get-unapplied; then
         # This zstyle call needs to be moved further up if `quilt' needs
         # to be run in more places than this one.
         zstyle -s "${context}" quiltcommand quiltcommand || quiltcommand='quilt'
-        if [ -z "$patches" ]; then
-            zstyle -s "${context}" quilt-patch-dir patches || patches="${QUILT_PATCHES}"
-            : ${patches:="patches"}
-            if [[ "${patches}" != /* ]]; then
-                if VCS_INFO_quilt-dirfind "${patches}"; then
-                    patches="$REPLY/${patches}"
-                else
-                    return $?
-                fi
-            else
-                [[ -d ${patches} ]] || return 1
-            fi
-            quilt_env+=(QUILT_PATCHES="$patches")
-        fi
         unapplied=( ${(f)"$(if (( $+quilt_env[1] )); then export ${quilt_env[@]}; fi
                             $quiltcommand --quiltrc /dev/null unapplied 2> /dev/null)"} )
         unapplied=( ${unapplied:#} )
@@ -154,8 +159,7 @@ function VCS_INFO_quilt-patch2subject() {
         unapplied=()
     fi
 
-    if [[ -n $patches ]]; then
-      () {
+    {
         local i
         for ((i=1; i<=$#applied; i++)); do
           if VCS_INFO_quilt-patch2subject "$patches/$applied[$i]" && (( $+REPLY ))
@@ -173,8 +177,7 @@ function VCS_INFO_quilt-patch2subject() {
             unapplied[$i]+=" ?"
           fi
         done
-      }
-    fi
+    }
 
     VCS_INFO_set-patch-format 'applied' 'applied_string' \
                               'unapplied' 'unapplied_string' \


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH 2/2] vcs_info quilt: Use quilt-patch-dir and ${QUILT_PATCHES} even when get-unapplied hasn't been set
  2022-01-27 17:58 ` [PATCH 2/2] vcs_info quilt: Use quilt-patch-dir and ${QUILT_PATCHES} even when get-unapplied hasn't been set Daniel Shahaf
@ 2022-01-27 18:12   ` Daniel Shahaf
  0 siblings, 0 replies; 3+ messages in thread
From: Daniel Shahaf @ 2022-01-27 18:12 UTC (permalink / raw)
  To: zsh-workers; +Cc: Marc Finet

Daniel Shahaf wrote on Thu, 27 Jan 2022 17:58 +00:00:
> This affects the post-quilt hook.  Before this patch, if no patches have
> been applied and get-unapplied hasn't been set, the second argument to
> that hook would undergo null elision.
>
> The generation of patch subjects for the gen-applied-string,
> gen-unapplied-string, and set-patch-format hooks was unaffected since
> it was guarded by [[ -n $patches ]].

While we're on the subject of hooks, I've been wondering how to pass the
quilt patches dir path to my gen-applied-string hook.  (I have a hook
that does lsdiff on patches that have no header.)

Right now I'm just using $patches, since, well, that works.

The post-quilt hook gets that value passed to it, but that doesn't help
since it runs _after_ gen-applied-string.

I suppose I could add another hook that runs sooner…

Cheers,

Daniel


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-01-27 18:14 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-27 17:58 [PATCH 1/2] vcs_info quilt: Refactor for readability. No functional change Daniel Shahaf
2022-01-27 17:58 ` [PATCH 2/2] vcs_info quilt: Use quilt-patch-dir and ${QUILT_PATCHES} even when get-unapplied hasn't been set Daniel Shahaf
2022-01-27 18:12   ` Daniel Shahaf

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).