From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 12254 invoked by alias); 23 Nov 2016 21:22:22 -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: 40006 Received: (qmail 17832 invoked from network); 22 Nov 2016 04:16:23 -0000 X-Qmail-Scanner-Diagnostics: from out5-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.29):SA:0(-0.7/5.0):. Processed in 2.596862 secs); 22 Nov 2016 04:16:23 -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, 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=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-sender:x-me-sender:x-sasl-enc:x-sasl-enc; s= mesmtp; bh=mMTp8iQInK2OQphG+5hZptbtNWw=; b=d6vcb/Ww2Adv21ZG52CI2 GeiV5yTAc8qznPi0nMdebwAJvdUVyit5/zZf3VhGaokYS2GAloHAvoE/MmUo4ofU 3YpQnsgtWZ9Z698BMQ7F1EEd0u4eNzWhu2E3c0Nphdzqxuko1Clc/LaBTbdeqFVP OawXsc/BeFNFiGsgGyVR08= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-sender:x-me-sender:x-sasl-enc:x-sasl-enc; s= smtpout; bh=mMTp8iQInK2OQphG+5hZptbtNWw=; b=oa1DXEryVlDfnLdyRAbs Xi4ltR/ygErJ3JCLwSEijejJg1FMdMLjj995A2Ik5VHOwGcmDLU/3McuJvTbGtVU NzmMLJr9W0feDzC/FuNroS9+gWDUboAHhjW3FUggMu0hgYMjc06Zg4WicykQqX3B 5taHVQ3TL/GEc+jAdwSQ4hM= X-ME-Sender: X-Sasl-enc: jUVDtHfsqp+HEHgQ8UxwKdAUnMGqwlGdm9oKG9UfQ26q 1479788170 Date: Tue, 22 Nov 2016 04:13:48 +0000 From: Daniel Shahaf To: Daniel Hahler Cc: zsh-workers@zsh.org Subject: Re: [PATCH] [RFC] Get subject of current patch in rebase-apply mode Message-ID: <20161122041348.GA21742@fujitsu.shahaf.local2> References: <20161120013325.12113-1-genml+zsh-workers@thequod.de> <20161120013325.12113-2-genml+zsh-workers@thequod.de> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20161120013325.12113-2-genml+zsh-workers@thequod.de> User-Agent: Mutt/1.5.23 (2014-03-12) Daniel Hahler wrote on Sun, Nov 20, 2016 at 02:33:25 +0100: > From: Daniel Hahler > > --- > Functions/VCS_Info/Backends/VCS_INFO_get_data_git | 9 +++++++++ > 1 file changed, 9 insertions(+) > > diff --git a/Functions/VCS_Info/Backends/VCS_INFO_get_data_git b/Functions/VCS_Info/Backends/VCS_INFO_get_data_git > index 18ba89a..93172fc 100644 > --- a/Functions/VCS_Info/Backends/VCS_INFO_get_data_git > +++ b/Functions/VCS_Info/Backends/VCS_INFO_get_data_git > @@ -236,6 +236,15 @@ elif [[ -d "${gitdir}/rebase-apply" ]]; then > done > if [[ -f "${patchdir}/msg-clean" ]]; then > subject="${$(< "${patchdir}/msg-clean")[(f)1]}" I use an older version of git that still creates msg-clean files (see 36830), so I rm'd the msg-clean file by hand to test your patch. > + else > + local maxlines=10 > + while IFS='\n' read -r; do Change '\n' to $'\n'. (But read the last paragraph first.) > + if [[ "$REPLY" == "Subject:"* ]]; then > + subject=${REPLY/(#s)Subject: /} > + break > + fi > + (( --maxlines )) || break > + done < "${patchdir}/$(printf "%04d" $cur)" I'm not an expert on git internal data structures, but I see two failure modes to this patch: the file "$patchdir/${(l:4::0:)cur}" might not exist, or might correspond to a different commit than $cur. The former case could be addressed by adding a [[ -f ]] existence check, as elsewhere in the file. The latter would cause information for a wrong commit to be printed instead of a commit hash. That would be a bug, but it seems unlikely enough. So I would suggest two code changes: use «${(l:4::0:)cur}» or the new 'printf -v' instead of a command substitution to save a fork on Cygwin, and consider adding a [[ -f ]] check to prevent error messages. One last thing I'd suggest is to consider using VCS_INFO_quilt-patch2subject, since it implements rfc822 unfolding of long subject lines. Cheers, Daniel > fi > if [[ -f "${patchdir}/original-commit" ]]; then > if [[ -n $subject ]]; then > -- > 2.10.2 > >