From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 26552 invoked by alias); 30 Sep 2015 18:38:04 -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: 36725 Received: (qmail 87 invoked from network); 30 Sep 2015 18:38:01 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,T_DKIM_INVALID autolearn=ham autolearn_force=no version=3.4.0 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-sasl-enc :x-sasl-enc; s=mesmtp; bh=SL0MqiuqGH3laYiYC4taPj2sOMY=; b=sDzhBz bkWvf5I+JAnFUf7FymeB1FdRXxRee1S7akt0XxETTR5OW8gNjrAkjx8s843Ak+2T xiBdSzSlHKT2VsH1WQ5WkHxFkqpbU/F8BinUbJhbGnxloqG9gOtEN15hpsmRIecf GmDBUeOtU/0H6C88z4eu6zNN3qunNz1D6YosY= 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-sasl-enc :x-sasl-enc; s=smtpout; bh=SL0MqiuqGH3laYiYC4taPj2sOMY=; b=pQ60w LfkyKkvh804UG8bYjkdFh9iTO5CzKItZx2lmur4t+gqxvv6Wv/zCcURztDMAGuUk o5T8rp9lUO64jXlMBXhnDD6U2KR0cvwdLI25nWUshj90SG7ExmdkTW4kQzDsdpoG y4vwKrw2yBzsfviCfrrlMctKc+ESmR26rLa2Yw= X-Sasl-enc: gqMnwuATquB/Pqt3PftAa80/imv4Ry+vy/74ozPFmXxp 1443637728 Date: Wed, 30 Sep 2015 18:28:45 +0000 From: Daniel Shahaf To: zsh-workers@zsh.org Subject: [PATCH x3] vcs_info git: $gitbranch when operating from detached heads Message-ID: <20150930182845.GC2003@tarsus.local2> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="ZPt4rx8FFjLCG7dd" Content-Disposition: inline Content-Transfer-Encoding: 8bit User-Agent: Mutt/1.5.21 (2010-09-15) --ZPt4rx8FFjLCG7dd Content-Type: text/plain; charset=us-ascii Content-Disposition: inline I ran into the third patch while reproducing PWS's report from 36717. The patches are semantically independent, each touches a different branch of the if-else chain. Also available from: git fetch git://github.com/danielshahaf/zsh/ vcs_info-nonsymbolic --ZPt4rx8FFjLCG7dd Content-Type: text/x-patch; charset=us-ascii Content-Disposition: attachment; filename="0001-vcs_info-git-Compute-b-correctly-when-merging-to-det.patch" >>From 9fb02f01a958af9ab4369e65f8663b50ec131a10 Mon Sep 17 00:00:00 2001 From: Daniel Shahaf Date: Wed, 30 Sep 2015 14:21:59 +0000 Subject: [PATCH 1/3] vcs_info git: Compute %b correctly when merging to detached heads. The %b expando should be the hash prior to the merge. The hash of the merge result is available as the %i expando and via the gen-applied-string hook. --- Functions/VCS_Info/Backends/VCS_INFO_get_data_git | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Functions/VCS_Info/Backends/VCS_INFO_get_data_git b/Functions/VCS_Info/Backends/VCS_INFO_get_data_git index 8ecc7c7..312f17c 100644 --- a/Functions/VCS_Info/Backends/VCS_INFO_get_data_git +++ b/Functions/VCS_Info/Backends/VCS_INFO_get_data_git @@ -90,7 +90,7 @@ VCS_INFO_git_getbranch () { elif [[ -f "${gitdir}/MERGE_HEAD" ]] ; then gitbranch="$(${(z)gitsymref} 2> /dev/null)" - [[ -z ${gitbranch} ]] && gitbranch="$(< ${gitdir}/MERGE_HEAD)" + [[ -z ${gitbranch} ]] && gitbranch="$(< ${gitdir}/ORIG_HEAD)" elif [[ -d "${gitdir}/rebase-merge" ]] ; then gitbranch="$(< ${gitdir}/rebase-merge/head-name)" -- 2.1.4 --ZPt4rx8FFjLCG7dd Content-Type: text/x-patch; charset=us-ascii Content-Disposition: attachment; filename="0002-vcs_info-git-Compute-b-correctly-when-rebasing-detac.patch" >>From 1a98630697c3193c496940c2acf14202a7d5097e Mon Sep 17 00:00:00 2001 From: Daniel Shahaf Date: Wed, 30 Sep 2015 14:21:59 +0000 Subject: [PATCH 2/3] vcs_info git: Compute %b correctly when rebasing detached heads. This sets the %b expando to the hash of the before-the-merge HEAD, rather than to the literal string "detached HEAD". That hash is already available via the gen-applied-string hook. --- Functions/VCS_Info/Backends/VCS_INFO_get_data_git | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Functions/VCS_Info/Backends/VCS_INFO_get_data_git b/Functions/VCS_Info/Backends/VCS_INFO_get_data_git index 312f17c..0a2a8bc 100644 --- a/Functions/VCS_Info/Backends/VCS_INFO_get_data_git +++ b/Functions/VCS_Info/Backends/VCS_INFO_get_data_git @@ -94,6 +94,10 @@ VCS_INFO_git_getbranch () { elif [[ -d "${gitdir}/rebase-merge" ]] ; then gitbranch="$(< ${gitdir}/rebase-merge/head-name)" + if [[ $gitbranch == 'detached HEAD' ]]; then + # get a sha1 + gitbranch="$(< ${gitdir}/rebase-merge/orig-head)" + fi elif [[ -d "${gitdir}/.dotest-merge" ]] ; then gitbranch="$(< ${gitdir}/.dotest-merge/head-name)" -- 2.1.4 --ZPt4rx8FFjLCG7dd Content-Type: text/x-patch; charset=iso-8859-1 Content-Disposition: attachment; filename="0003-vcs_info-git-Compute-b-correctly-when-git-am-ing-ont.patch" Content-Transfer-Encoding: 8bit >>From 47697fe326c1eb6d022db2a2b3425bf1bf5ffd85 Mon Sep 17 00:00:00 2001 From: Daniel Shahaf Date: Wed, 30 Sep 2015 14:21:59 +0000 Subject: [PATCH 3/3] vcs_info git: Compute %b correctly when "git am"-ing onto detached heads. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Before this patch, $gitbranch would be set to empty, which caused VCS_INFO_get_data_git to early out with a failure status¹, consequently $vcs_info_msg_0_ would be empty. ¹ via the 'if [[ -z ]]' block around line 170. --- Functions/VCS_Info/Backends/VCS_INFO_get_data_git | 1 + 1 file changed, 1 insertion(+) diff --git a/Functions/VCS_Info/Backends/VCS_INFO_get_data_git b/Functions/VCS_Info/Backends/VCS_INFO_get_data_git index 0a2a8bc..8664d51 100644 --- a/Functions/VCS_Info/Backends/VCS_INFO_get_data_git +++ b/Functions/VCS_Info/Backends/VCS_INFO_get_data_git @@ -87,6 +87,7 @@ VCS_INFO_git_getbranch () { gitbranch="$(${(z)gitsymref} 2> /dev/null)" [[ -z ${gitbranch} ]] && [[ -r ${actiondir}/head-name ]] \ && gitbranch="$(< ${actiondir}/head-name)" + [[ -z ${gitbranch} ]] && gitbranch="$(< ${gitdir}/ORIG_HEAD)" elif [[ -f "${gitdir}/MERGE_HEAD" ]] ; then gitbranch="$(${(z)gitsymref} 2> /dev/null)" -- 2.1.4 --ZPt4rx8FFjLCG7dd--