zsh-workers
 help / color / Atom feed
* [PATCH 1/5] vcs_info examples: Add an example of showing Git environment variables.
@ 2019-12-21 15:58 Daniel Shahaf
  2019-12-21 15:58 ` [PATCH 2/5] vcs_info examples: Make the quilt-patch-dir example friendlier Daniel Shahaf
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Daniel Shahaf @ 2019-12-21 15:58 UTC (permalink / raw)
  To: zsh-workers

---
 Misc/vcs_info-examples | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/Misc/vcs_info-examples b/Misc/vcs_info-examples
index c46fad93a..028fe62b0 100644
--- a/Misc/vcs_info-examples
+++ b/Misc/vcs_info-examples
@@ -222,6 +222,31 @@ zstyle -e ':vcs_info:git+set-message:*' hooks 'reply=( ${${(k)functions[(I)[+]vi
 # Both of these functions would be called, even if they are defined after the zstyle is set.
 
 
+## git: Display pertinent environment variables
+# If environment variables such as $GIT_DIR, $GIT_WORK_TREE, etc are set in the
+# environment, they'll be shown in the value of the %m expando.
+#
+# Note that the %m expando is not used by default. To see a change, either change
+# `[misc]' to `[branch]', or set the `formats` style to a value that includes `%m'.
+zstyle ':vcs_info:git+post-backend:*' hooks git-post-backend-envvars
++vi-git-post-backend-envvars() {
+  local param
+  # This uses the ${parameters} special variable (provided by the zsh/parameter
+  # module), in conjunction with the parameter expansion flags ${(k)foo} and
+  # ${(M)foo:#pattern} (documented in "Parameter Expansion" in zshexpn(1))
+  # and the (R) subscript flag (documented in "Subscript Flags" in zshparam(1)),
+  # to iterate over the names of all environment variables named "GIT_*".  Then
+  # it uses the ${(P)foo} parameter expansion flag to show the values of those
+  # parameters.
+  #
+  # The value of ${hook_com[misc]} is substituted for %m in the values of the
+  # 'formats' and 'actionformats' styles.
+  for param in ${(Mk)parameters[(R)*export*]:#GIT_*}; do
+    hook_com[misc]+=";%U${param//'%'/%%}%u=%F{white}${${(P)param}//'%'/%%}%f"
+  done
+}
+
+
 ### hg: Show marker when the working directory is not on a branch head
 # This may indicate that running `hg up` will do something
 # NOTE: the branchheads.cache file is not updated with every Mercurial

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

* [PATCH 2/5] vcs_info examples: Make the quilt-patch-dir example friendlier.
  2019-12-21 15:58 [PATCH 1/5] vcs_info examples: Add an example of showing Git environment variables Daniel Shahaf
@ 2019-12-21 15:58 ` Daniel Shahaf
  2019-12-21 15:58 ` [PATCH 3/5] vcs_info quilt: Improve support for svn-style patch headers Daniel Shahaf
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Daniel Shahaf @ 2019-12-21 15:58 UTC (permalink / raw)
  To: zsh-workers

- Document that no code at all is necessary for Pareto correctness

- Remove a recommendation to rely on implementation details (${rrn});
  instead, rely only on ${context}, which is a documented API.
---
 Misc/vcs_info-examples | 30 ++++++++++++++++++------------
 1 file changed, 18 insertions(+), 12 deletions(-)

diff --git a/Misc/vcs_info-examples b/Misc/vcs_info-examples
index 028fe62b0..456b3a85b 100644
--- a/Misc/vcs_info-examples
+++ b/Misc/vcs_info-examples
@@ -468,8 +468,16 @@ zstyle ':vcs_info:-quilt-.quilt-standalone:*:*' quilt-patch-dir debian/patches
 # and so we want addon mode to also use a $QUILT_PATCHES value of
 # `debian/patches' in some directories. In the other directories we never
 # want the default `patches' though but a dedicated place for them.
-# Say `~/patches/<repository-name>'. Now we'll use some evaluated-style
-# magic to achieve all that:
+# Say `~/patches/<repository-name>'.
+#
+# First of all, even without any configuration, vcs_info will do the right
+# thing most of the time. Whenever quilt has already run in a directory,
+# vcs_info will figure out whether that directory uses `patches' or
+# `debian/patches' by interrogating metadata in the `.pc/' subdirectory,
+# which quilt creates. To make vcs_info find the patches dir correctly even
+# when the `.pc/' directory doesn't exist, read on.
+#
+# We'll use some evaluated-style magic to achieve that:
 zstyle -e ':vcs_info:*.quilt-addon:*:*' quilt-patch-dir 'my-patches-func'
 
 # That runs something called `my-patches-func', and the value of $reply is
@@ -486,19 +494,17 @@ function my-patches-func() {
     fi
 
     # Now the part about the dedicated directory is a little trickier.
-    # It requires some knowledge of vcs_info's internals. Not much though.
-    # Everything about this is described in the manual because this
-    # variable (plus a few others) may be of interest in hooks, where
-    # they are available, too.
-    #
-    # The variable in question here is `$rrn' which is an abbreviation
-    # of repository-root-name. if you're in
+    # The variable in question here is `$context', which is the zstyle
+    # context used for lookups. Its last component is the repository-root-name,
+    # or ${rrn} for short. If you're in
     #   /usr/src/zsh/Functions
     # and the repository being
     #   /usr/src/zsh
-    # then the value of `$rrn' is `zsh'. Now in case the variable is
-    # empty (it shouldn't at this point, but you never know), let's
-    # drop back to quilt's default "patches".
+    # then the value of `$rrn' would be `zsh'.
+    local rrn=${context##*:}
+
+    # Now, in case the variable is empty (it shouldn't at this point, but you
+    # never know), let's drop back to quilt's default value, "patches".
     if [[ -z ${rrn} ]]; then
         reply=( patches )
         return 0

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

* [PATCH 3/5] vcs_info quilt: Improve support for svn-style patch headers.
  2019-12-21 15:58 [PATCH 1/5] vcs_info examples: Add an example of showing Git environment variables Daniel Shahaf
  2019-12-21 15:58 ` [PATCH 2/5] vcs_info examples: Make the quilt-patch-dir example friendlier Daniel Shahaf
@ 2019-12-21 15:58 ` Daniel Shahaf
  2019-12-21 15:58 ` [PATCH 4/5] vcs_info docs: Clarify documentation of the %p/%u/%a patch-format expandos Daniel Shahaf
  2019-12-21 15:58 ` [PATCH 5/5] zshmodules: Explicitly document the return values of the 'zstyle' getters -s, -b, and -a Daniel Shahaf
  3 siblings, 0 replies; 5+ messages in thread
From: Daniel Shahaf @ 2019-12-21 15:58 UTC (permalink / raw)
  To: zsh-workers

Additional lines between the |-separated header line and the actual
log message, as generated by 'svn log -v' and 'svn log -g', are now
supported.

This change affects you if you have quilt patches with 'svn log'-style
information in their headers, regardless of whether you use quilt
standalone, quilt over svn, or quilt over some other VCS.
---
 Functions/VCS_Info/VCS_INFO_patch2subject | 20 +++++++++++++-------
 1 file changed, 13 insertions(+), 7 deletions(-)

diff --git a/Functions/VCS_Info/VCS_INFO_patch2subject b/Functions/VCS_Info/VCS_INFO_patch2subject
index a48c16b04..a467edcdb 100644
--- a/Functions/VCS_Info/VCS_INFO_patch2subject
+++ b/Functions/VCS_Info/VCS_INFO_patch2subject
@@ -14,10 +14,7 @@
             IFS= read -r "lines[$i]"
             if [[ -z ${lines[$i]} ]] || [[ ${lines[$i]} == (#b)(---[^-]|Index:)* ]]; then
                 lines[$i]=()
-                # For 'svn log -r N --diff' output, read the first paragraph too.
-                if ! [[ $lines[i-1] =~ $svn_log_pattern ]]; then
-                    break
-                fi
+                break
             fi
         done < "$1"
         
@@ -55,9 +52,18 @@
               fi
             } < "$1"
             REPLY=$needle
-        elif [[ $lines[2] =~ $svn_log_pattern ]]; then
-            REPLY=$lines[4]
-            if (( ${+lines[5]} )); then REPLY+='...'; fi
+        elif [[ $lines[1] =~ $svn_log_pattern ]] || [[ $lines[2] =~ $svn_log_pattern ]]; then
+            # Read up to the next blank line, and the first two lines after it.
+            integer multiline=0
+            {
+              while read -r needle; [[ -n $needle ]]; do done
+              # Read the first line of the second paragraph, which is the first
+              # line of the log message.
+              read -r needle
+              read -r && [[ -n $REPLY ]] && multiline=1
+            } < "$1"
+            REPLY=$needle
+            if (( multiline )); then REPLY+='...'; fi
         elif (( ${+lines[1]} )); then
             # The first line of the file is not part of the diff.
             REPLY=${lines[1]}

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

* [PATCH 4/5] vcs_info docs: Clarify documentation of the %p/%u/%a patch-format expandos.
  2019-12-21 15:58 [PATCH 1/5] vcs_info examples: Add an example of showing Git environment variables Daniel Shahaf
  2019-12-21 15:58 ` [PATCH 2/5] vcs_info examples: Make the quilt-patch-dir example friendlier Daniel Shahaf
  2019-12-21 15:58 ` [PATCH 3/5] vcs_info quilt: Improve support for svn-style patch headers Daniel Shahaf
@ 2019-12-21 15:58 ` Daniel Shahaf
  2019-12-21 15:58 ` [PATCH 5/5] zshmodules: Explicitly document the return values of the 'zstyle' getters -s, -b, and -a Daniel Shahaf
  3 siblings, 0 replies; 5+ messages in thread
From: Daniel Shahaf @ 2019-12-21 15:58 UTC (permalink / raw)
  To: zsh-workers

---
 Doc/Zsh/contrib.yo | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/Doc/Zsh/contrib.yo b/Doc/Zsh/contrib.yo
index d51fd518b..558342711 100644
--- a/Doc/Zsh/contrib.yo
+++ b/Doc/Zsh/contrib.yo
@@ -1343,11 +1343,11 @@ endsitem()
 In tt(patch-format) and tt(nopatch-format) these replacements are done:
 
 startsitem()
-sitem(tt(%p))(The name of the top-most applied patch (tt(applied-string)).)
-sitem(tt(%u))(The number of unapplied patches (tt(unapplied-string)).)
+sitem(tt(%p))(The name of the top-most applied patch; may be overridden by the tt(applied-string) hook.)
+sitem(tt(%u))(The number of unapplied patches; may be overridden by the tt(unapplied-string) hook.)
 sitem(tt(%n))(The number of applied patches.)
 sitem(tt(%c))(The number of unapplied patches.)
-sitem(tt(%a))(The number of all patches.)
+sitem(tt(%a))(The number of all patches (tt(%a = %n + %c)).)
 sitem(tt(%g))(The names of active tt(mq) guards (tt(hg) backend).)
 sitem(tt(%G))(The number of active tt(mq) guards (tt(hg) backend).)
 endsitem()

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

* [PATCH 5/5] zshmodules: Explicitly document the return values of the 'zstyle' getters -s, -b, and -a.
  2019-12-21 15:58 [PATCH 1/5] vcs_info examples: Add an example of showing Git environment variables Daniel Shahaf
                   ` (2 preceding siblings ...)
  2019-12-21 15:58 ` [PATCH 4/5] vcs_info docs: Clarify documentation of the %p/%u/%a patch-format expandos Daniel Shahaf
@ 2019-12-21 15:58 ` Daniel Shahaf
  3 siblings, 0 replies; 5+ messages in thread
From: Daniel Shahaf @ 2019-12-21 15:58 UTC (permalink / raw)
  To: zsh-workers

---
 Doc/Zsh/mod_zutil.yo | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/Doc/Zsh/mod_zutil.yo b/Doc/Zsh/mod_zutil.yo
index fa1f7b3ea..1e35d2245 100644
--- a/Doc/Zsh/mod_zutil.yo
+++ b/Doc/Zsh/mod_zutil.yo
@@ -81,17 +81,23 @@ item(tt(zstyle -s) var(context) var(style) var(name) [ var(sep) ])(
 The parameter var(name) is set to the value of the style interpreted as a
 string.  If the value contains several strings they are concatenated with
 spaces (or with the var(sep) string if that is given) between them.
+
+Return tt(0) if the style is set, tt(1) otherwise.
 )
 item(tt(zstyle -b) var(context) var(style) var(name))(
 The value is stored in var(name) as a boolean, i.e. as the string
 `tt(yes)' if the value has only one string and that string is equal to one
 of `tt(yes)', `tt(true)', `tt(on)', or `tt(1)'. If the value is any other
 string or has more than one string, the parameter is set to `tt(no)'.
+
+Return tt(0) if var(name) is set to `tt(yes)', tt(1) otherwise.
 )
 item(tt(zstyle -a) var(context) var(style) var(name))(
 The value is stored in var(name) as an array. If var(name) is declared 
 as an associative array,  the first, third, etc. strings are used as the
 keys and the other strings are used as the values.
+
+Return tt(0) if the style is set, tt(1) otherwise.
 )
 xitem(tt(zstyle -t) var(context) var(style) [ var(string) ... ])
 item(tt(zstyle -T) var(context) var(style) [ var(string) ... ])(

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

end of thread, back to index

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-12-21 15:58 [PATCH 1/5] vcs_info examples: Add an example of showing Git environment variables Daniel Shahaf
2019-12-21 15:58 ` [PATCH 2/5] vcs_info examples: Make the quilt-patch-dir example friendlier Daniel Shahaf
2019-12-21 15:58 ` [PATCH 3/5] vcs_info quilt: Improve support for svn-style patch headers Daniel Shahaf
2019-12-21 15:58 ` [PATCH 4/5] vcs_info docs: Clarify documentation of the %p/%u/%a patch-format expandos Daniel Shahaf
2019-12-21 15:58 ` [PATCH 5/5] zshmodules: Explicitly document the return values of the 'zstyle' getters -s, -b, and -a Daniel Shahaf

zsh-workers

Archives are clonable: git clone --mirror http://inbox.vuxu.org/zsh-workers

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://inbox.vuxu.org/vuxu.archive.zsh.workers


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git