From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.4 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 20389 invoked from network); 29 Mar 2021 09:53:11 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 29 Mar 2021 09:53:11 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20200801; t=1617011591; b=un/ZtXtRqjvGZ65wK8Wx41UN4iX05HTBiscTQ0xItogEKO0weGf7zpca93Eu7XD1B+i4SAOeG5 NnK24QipFrNJdGz2a8NCAiMu2Hil2juLchygqod+7enrQ25y5Za/HlYgcIhDeU5nmZqXUbHp1g i65gvjpGexwibscmeefqRl6NV7zoRumjhRpaI/0sN0qqkBUfYgCgSOivs2A80YLG50gT6JnH1g SHXYUkYsMbjjuPXtztl1kCmo69egt6iSiP4Br01pazdbstGLAM1XpEtAFss4aJ0q8MB4n38Crn E2D/tMBIUllsu8QXxCVqckqF3ppDNt77/GTmPpYRFGg5mg==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (out3-smtp.messagingengine.com) smtp.remote-ip=66.111.4.27; dkim=pass header.d=daniel.shahaf.name header.s=fm3 header.a=rsa-sha256; dkim=pass header.d=messagingengine.com header.s=fm2 header.a=rsa-sha256; dmarc=none header.from=daniel.shahaf.name; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20200801; t=1617011591; bh=ZKKQlbPGpyYkQUjQWwOtDKa1AktgaBDcGOGHGHzc7II=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Content-Transfer-Encoding:Content-Type:Subject:Cc:To:From: Date:References:In-Reply-To:Message-ID:MIME-Version:DKIM-Signature: DKIM-Signature:DKIM-Signature; b=xiRDUSqQtY8HAArvukvRRyF1Rs626tyW5fBl5pLKzbYGL0LJ3/WjLfMpTaBTMUVDxs4Ukg9fs/ XTxHVG0m/XVjUaKXUesNm8UJS1AFHMi3rvOtO/qi4Or65jll7cqCiU2hMnyFhT4b+OcO3jxVUN gXed5Czx1+KsmOWAwt/d4y3qJMSLph7hR3wCNYzq1xSg0/QZRTRszE8YW/EycUDAOmnaLbiV5R ty6H0eUJNYH9y1UqzN4VP9eaLgPltudGYd+nUryThcbWE9qvo5P4FHrzu8Jwg4lVyIDaihtN47 XohFi8ECUlRCs2pWqGFdg6S5JPl66UYVjNxiwisiLkO1eQ==; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=zsh.org; s=rsa-20200801; h=List-Archive:List-Owner:List-Post:List-Unsubscribe: List-Subscribe:List-Help:List-Id:Sender:Content-Transfer-Encoding: Content-Type:Subject:Cc:To:From:Date:References:In-Reply-To:Message-Id: Mime-Version:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=AXumgOnJI9iF/kHhOByoFyiL/+BZWxrXodcGKB3gda0=; b=tDaXd6LG6zR+fZLHxkLN49Z8OC y32kw/PeTAY0zp53MVEqxYlGsWilCKOXlLQRG1aryEMGDM6GaS3s023JXagb8XpuwMi4z6NDwqhcT ePgnPmywB5u+V2let664JmnxlUxqkGj42gHLsU8azchfWWp6eW/zZFQr2OwOQJq2q2ZFP8gnLnYti HVYExuiZsZx19if40nZUPm8UGcpfliZkjfAaabWjtypJZsHB58a2V31j9Oj7kd9a3fFwdmUHSXBVk iGn5l7+wYumHZRu7+VTwk+F8J8qMjclHiX/pZpWqxOeoKfN/uDMSZN16wuJy5ywF3Gcg2OsN3XtWi PngfI+/w==; Received: from authenticated user by zero.zsh.org with local id 1lQoa3-000NGi-0s; Mon, 29 Mar 2021 09:53:07 +0000 Authentication-Results: zsh.org; iprev=pass (out3-smtp.messagingengine.com) smtp.remote-ip=66.111.4.27; dkim=pass header.d=daniel.shahaf.name header.s=fm3 header.a=rsa-sha256; dkim=pass header.d=messagingengine.com header.s=fm2 header.a=rsa-sha256; dmarc=none header.from=daniel.shahaf.name; arc=none Received: from out3-smtp.messagingengine.com ([66.111.4.27]:60231) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_256_GCM_SHA384:256) id 1lQoZk-000N7O-03; Mon, 29 Mar 2021 09:52:49 +0000 Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.nyi.internal (Postfix) with ESMTP id 6017C5C00B0; Mon, 29 Mar 2021 05:52:46 -0400 (EDT) Received: from imap37 ([10.202.2.87]) by compute3.internal (MEProxy); Mon, 29 Mar 2021 05:52:46 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= daniel.shahaf.name; h=mime-version:message-id:in-reply-to :references:date:from:to:cc:subject:content-type :content-transfer-encoding; s=fm3; bh=AXumgOnJI9iF/kHhOByoFyiL/+ BZWxrXodcGKB3gda0=; b=D4wESR8K/7usmKQWIAZ+VmAa2MKbB2Na6niRHnwIff ih3HAdyLPv4dY5ixgtEdNN8CwGNfRUbYWha1hgR+sLcgDO1GKxODKZcI3ozCGI7o +vvIj73kPDuFWdVQ4Jf4ZcA2zPR6op90hysCGgsjsst1eqMvUMRcpPjJ3aPS4dTO GZennicpgOommLRHQBPGfkDKwBZlw0FHMLJPlD45Sh6tYKHb4Oz59lHW/ePv8gs0 QpYsbKglBy9DlCNnz6zToWxZDow7tt3J0LnpxlBDiKAFyVVt5s7n2MpXTUNVn52V Jo0lxJfYf7WosE+aO8OrymP19ZprTl0QQNBjV57hHM1w== DKIM-Signature: v=1; a=rsa-sha256; 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-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm2; bh=AXumgOnJI9iF/kHhOByoFyiL/+BZWxrXodcGKB3gd a0=; b=IQ1+IzIpPtqCRtMeKptQa6YSi1gCPbYUY4WiVZ7iywmlphSxq/USHVeM3 5HYxDiWd4EOHcNyqkEX+AkwjNGhLIizCZev91YQkEg3jbnxo8ztEWFwvJAAHtoVp Xx832ckUqEEt07OhhGg8o0dDUOq1PwsSXM73yrwBCfxOqaEIzVUGbCXSSdcYEJKD y13sYrhqZYmg8Qd1uAJMGGoAM1AwxhQ0CHPdHgc27yY0qVLPtNpAyJLEigHk/LL4 MsbrN34NVv4Ry1k8/LU5up7RQ17uQHSb3OzyYrG94ge+m3DfNxzkx+qk+L/G1mXR VxCS5NO1wIkB1jCte9+r7o/w5AkMw== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrudehkedgvdduucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefofgggkfgjfhffhffvufgtgfesth hqredtreerjeenucfhrhhomhepfdffrghnihgvlhcuufhhrghhrghffdcuoegurdhssegu rghnihgvlhdrshhhrghhrghfrdhnrghmvgeqnecuggftrfgrthhtvghrnhepheejiefhje efffehteehudfhueeiuedvleeuffeiheekvdeliefhhffhvedvudegnecuffhomhgrihhn pehgihhthhhusgdrtghomhenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmh grihhlfhhrohhmpegurdhssegurghnihgvlhdrshhhrghhrghfrdhnrghmvg X-ME-Proxy: Received: by mailuser.nyi.internal (Postfix, from userid 501) id B3EA56B40063; Mon, 29 Mar 2021 05:52:45 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.5.0-alpha0-273-g8500d2492d-fm-20210323.002-g8500d249 Mime-Version: 1.0 Message-Id: In-Reply-To: <20210329093056.fegqam75id4yfkiq@home-guest> References: <20210328213628.7rwz62bq5p2isd6b@home-guest> <20210329070611.GM18178@tarpaulin.shahaf.local2> <20210329093056.fegqam75id4yfkiq@home-guest> Date: Mon, 29 Mar 2021 09:52:25 +0000 From: "Daniel Shahaf" To: "Tim Lee" Cc: zsh-workers@zsh.org Subject: Re: [PATCH] Improve vcs_info example for ahead/behind git commits Content-Type: text/plain;charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Seq: 48312 Archived-At: X-Loop: zsh-workers@zsh.org Errors-To: zsh-workers-owner@zsh.org Precedence: list Precedence: bulk Sender: zsh-workers-request@zsh.org X-no-archive: yes List-Id: List-Help: List-Subscribe: List-Unsubscribe: List-Post: List-Owner: List-Archive: Archived-At: Tim Lee wrote on Mon, 29 Mar 2021 09:30 +00:00: > > > * Remove unnecessary use of `${hook_com[branch]}` because `@{upstr= eam}` > > > defaults to the current branch when no branch name is provided. > > > `@{upstream}` was introduced in git 1.7.0 > > > (https://github.com/git/git/commit/28fb84382b0eb728534dbe2972bbf= ec3f3d83dd9) > >=20 > > I'm not sure that's unnecessary, for two reasons: > >=20 > > 1. hook_com[branch], as opposed to hook_com[branch_orig], may have b= een > > changed by a previous hook. > >=20 > > 2. There may be educational value to demonstrating a use of > > hook_com[branch], even if it's implied. > >=20 > > WDYT? >=20 > Okay. I was not aware of these reasons. I am still very much a beginne= r > (both to zsh and to mailing lists ...). >=20 I couldn't tell that from your original mail =E2=98=BA > > > diff --git a/Misc/vcs_info-examples b/Misc/vcs_info-examples > > > index 94b8a7b5e..36d4d3bf8 100644 > > > --- a/Misc/vcs_info-examples > > > +++ b/Misc/vcs_info-examples > > > @@ -179,14 +179,18 @@ function +vi-git-st() { > > > local ahead behind > > > local -a gitstatus > > >=20 > > > - # for git prior to 1.7 > > > + # for git prior to 1.7.0 > > > # ahead=3D$(git rev-list origin/${hook_com[branch]}..HEAD | w= c -l) > > > - ahead=3D$(git rev-list ${hook_com[branch]}@{upstream}..HEAD 2= >/dev/null | wc -l) > > > + # for git 1.7.0 and 1.7.1 > > > + # ahead=3D$(git rev-list @{upstream}..HEAD 2>/dev/null | wc -= l) > > > + ahead=3D$(git rev-list --count @{upstream}..HEAD 2>/dev/null)= > > > (( $ahead )) && gitstatus+=3D( "+${ahead}" ) > >=20 > > The version of this function in my zshrc starts like this: > > . > > git rev-parse @{upstream} >/dev/null 2>&1 || return 0 > > local -a x=3D( $(git rev-list --left-right --count HEAD...@{upst= ream} ) ) >=20 > The snippet below displays N/M. How would you make it display +N/-M > instead? Change the last line to hook_com[misc]=3D"+${x[1]} -${x[2]}". > git rev-parse @{upstream} >/dev/null 2>&1 || return 0 > local -a x=3D( $(git rev-list --left-right --count HEAD...@{upstre= am} ) ) > hook_com[misc]=3D"${(j:/:)x}" >=20 > > The first line is to handle a detached HEAD, I think, and should > > presumably be added? >=20 > Why not do this instead: >=20 > local -a x=3D( $(git rev-list --left-right --count HEAD...@{upstre= am} 2>/dev/null ) ) You mean, why not discard stderr? Out of general principles ("Errors shouldn't be silenced"), plus the fact that I've never had that line generate an error that needed to be silenced=C2=A0=E2=80=94 not with the= =C2=ABgit rev-parse =E2=80=A6 || return=C2=BB right above it. Or do you mean that line instead of the git-rev-parse(1) call too? First, that would run the rest of the function even though $x might be an empty array rather than a two-element one. Two, suppose there is an error after resolving =C2=AB@{upstream}=C2=BB to a commit but before rev= -list finishes (for instance, an error while walking the commits history). With an explicit git-rev-parse(1) call that error would be reported, but= if the rev-parse and the history walking are lumped into one step any failure from which is treated the same way, history walking failures would be masked=C2=A0=E2=80=94 even though they're probably interesting.= > --- > Note: when replying to my email, please ensure that my email address i= s > included in the 'To:' field, since I am not subscribed to the mailing > list. Ack, but for future reference, the customary signature delimiter is "-- = " (ASCII 0x2D 0x2D 0x20). Many MUAs syntax-highlight that, for example. Cheers, Daniel