From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 11285 invoked by alias); 21 Jan 2017 12:16:20 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 40392 Received: (qmail 24916 invoked from network); 21 Jan 2017 12:16:20 -0000 X-Qmail-Scanner-Diagnostics: from out1-smtp.messagingengine.com by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.99.2/21882. spamassassin: 3.4.1. Clear:RC:0(66.111.4.25):SA:0(-0.7/5.0):. Processed in 1.562982 secs); 21 Jan 2017 12:16:20 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-0.7 required=5.0 tests=RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.1 X-Envelope-From: d.s@daniel.shahaf.name X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | Received-SPF: none (ns1.primenet.com.au: domain at daniel.shahaf.name does not designate permitted sender hosts) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= daniel.shahaf.name; h=content-transfer-encoding:content-type :date:from:message-id:mime-version:subject:to:x-me-sender :x-me-sender:x-sasl-enc:x-sasl-enc; s=mesmtp; bh=gOPIbVV7vgK9z/f +W/mFZI075wQ=; b=NjYZd4CeFNf6H3X2bQUh6HJMnwkWpPCI0lvOwZDQ8DVri4j sbXs1lQ4FZtzouPOlHHQO5i/xAnT+LBqiIQW+p3GYxrtFPsJ/eganle8Rmo+Np1O K2IqdUbbMBLrdQOdpIickOiy5uIzGxHzq2FFN9nCjL66ohk0k3XwC3SYZMz4= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=content-transfer-encoding:content-type :date:from:message-id:mime-version:subject:to:x-me-sender :x-me-sender:x-sasl-enc:x-sasl-enc; s=smtpout; bh=gOPIbVV7vgK9z/ f+W/mFZI075wQ=; b=W6SYcqPglYuQadSUInDC6Qmd/Tc14YQRWyAnp38kU7d6t+ gCVsPG50Q1h2MPdQ+lN7kmXRMTMk0TuOi/92lLIDEJVqZFt6cqyMlGFC6ieP+weo Br+CCzTUzTDM2POvARC4AFdYLMhrcsgLCo+CqeT8H9sa2IGZGEVIzowDLN1GM= X-ME-Sender: X-Sasl-enc: y6NRvN9qJFIQEJcYl5HBWsG+mkQdMXnvSsME9vYIU7uN 1485000971 From: Daniel Shahaf To: zsh-workers@zsh.org Subject: [PATCH] vcs_info patch2subject: Support `git show` output. Date: Sat, 21 Jan 2017 12:12:31 +0000 Message-Id: <1485000751-24044-1-git-send-email-danielsh@fujitsu.shahaf.local2> X-Mailer: git-send-email 2.1.4 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Personally I'd have used a Unicode ellipsis (…) instead of an ASCII one in the «needle+=» line, but it's only 2017... Cheers, Daniel Functions/VCS_Info/VCS_INFO_patch2subject | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/Functions/VCS_Info/VCS_INFO_patch2subject b/Functions/VCS_Info/VCS_INFO_patch2subject index 583467b..bbd3c8d 100644 --- a/Functions/VCS_Info/VCS_INFO_patch2subject +++ b/Functions/VCS_Info/VCS_INFO_patch2subject @@ -1,6 +1,7 @@ # 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. { + setopt localoptions extendedglob integer i integer -r LIMIT=10 local -a lines @@ -34,6 +35,22 @@ elif [[ ${lines[1]} == '# HG changeset patch' ]] && { needle=${${lines:#([#]*)}[1]}; [[ -n $needle ]] }; then # Mercurial patch REPLY=$needle + elif [[ ${lines[1]} == "commit "[0-9a-f](#c40) ]] && + [[ ${lines[2]} == "Author:"* && ${lines[3]} == "Date:"* ]] && + (( ! ${+lines[4]} )); then + # `git show` output. + # + # The log message is after the first blank line, so open() the file + # again. Also check whether the following line (second line of the + # log message itself) is empty. + { + repeat 4 { IFS= read -r } + IFS= read -r needle; needle=${needle#' '} + if IFS= read -r; REPLY=${REPLY#' '}; [[ -n $REPLY ]]; then + needle+='...' + fi + } < "$1" + REPLY=$needle elif (( ${+lines[1]} )); then # The first line of the file is not part of the diff. REPLY=${lines[1]}