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 patch2subject: Support `svn log -r N --diff` output.
Date: Thu, 17 Aug 2017 17:26:39 +0000	[thread overview]
Message-ID: <20170817172639.24034-1-danielsh@tarpaulin.shahaf.local2> (raw)

---
This is used by the Debian libserf-1-1 package.

 Functions/VCS_Info/VCS_INFO_patch2subject | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/Functions/VCS_Info/VCS_INFO_patch2subject b/Functions/VCS_Info/VCS_INFO_patch2subject
index e222e8382..a48c16b04 100644
--- a/Functions/VCS_Info/VCS_INFO_patch2subject
+++ b/Functions/VCS_Info/VCS_INFO_patch2subject
@@ -6,14 +6,18 @@
     integer -r LIMIT=10
     local -a lines
     local needle
+    readonly svn_log_pattern='^r[0-9]* [|] .*'
     if [[ -f "$1" ]]; then
         # Extract the first LIMIT lines, or up to the first empty line or the start of the unidiffs,
         # whichever comes first.
         while (( i++ < LIMIT )); do
             IFS= read -r "lines[$i]"
-            if [[ -z ${lines[$i]} ]] || [[ ${lines[$i]} == (#b)(---|Index:)* ]]; then
+            if [[ -z ${lines[$i]} ]] || [[ ${lines[$i]} == (#b)(---[^-]|Index:)* ]]; then
                 lines[$i]=()
-                break
+                # For 'svn log -r N --diff' output, read the first paragraph too.
+                if ! [[ $lines[i-1] =~ $svn_log_pattern ]]; then
+                    break
+                fi
             fi
         done < "$1"
         
@@ -51,6 +55,9 @@
               fi
             } < "$1"
             REPLY=$needle
+        elif [[ $lines[2] =~ $svn_log_pattern ]]; then
+            REPLY=$lines[4]
+            if (( ${+lines[5]} )); then REPLY+='...'; fi
         elif (( ${+lines[1]} )); then
             # The first line of the file is not part of the diff.
             REPLY=${lines[1]}


                 reply	other threads:[~2017-08-17 17:26 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=20170817172639.24034-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).