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 371 invoked from network); 13 Apr 2021 14:01:56 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 13 Apr 2021 14:01:56 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20200801; t=1618322516; b=Jt7IPKoRx6B1yPC0jAxJX5/PJzF76fCHCdRx+spm5/WD/nkcASWNMfa6Ooj14UMgaS9bbMVDbh BVUHGiG9x6y4KG4clt4wn/C6MlmqOoZXGHKsqNI+CGKcmaMBs5iE+pQDiv95+yPQ9DIO1qWeOs cbLMuXUXChKj61rmDkELA2rbYvMMcgSQ5GkpmdnDLf+tuS1Df41JEbch9ysBgU1+OIaZh4RXz1 hIAdpDz4ZvJZt1r8vGlFx3d+ebUZJWO9DhpdWhjzkrfzQqAa9H9IDKB3Qud5g1hQf/Ip8LD32V n5Oguzj1PiSNMO+tJ3V9Kjn7GB7UiTzGaXfJDVJ6cnYx2w==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (out2-smtp.messagingengine.com) smtp.remote-ip=66.111.4.26; 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=1618322516; bh=8T9lj0XGHVW9XBYcUOQ5nsLO4rXHXAI1Vv1wCHx4jK8=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:In-Reply-To:Content-Type:MIME-Version:References:Message-ID: Subject:Cc:To:From:Date:DKIM-Signature:DKIM-Signature:DKIM-Signature; b=WVhhKojXFo2d0QfAVceay2BFwpbUQ827KEvGyj30Qzxba8500Nq4PpV/8ZqQFVW0pT/0/85Ml9 8LzgAq+aC4Bkgj9Wi4WJ8pJ4ADszz+dRw+UneoNX+W515MsdSB4fEXgB1EcFXaKPMAMgqI2VCS VemC1TuW4cHTYvP+qBxqvf6MyTbC/utPqP5FQInkSw4P6UFD/ALMNXaLBY4R4vFGeSX1h5qffP y/jeAo+kAQdtrAFVEltZfa8riHCJQBjSfnZVNP2UNVsShcAbMrk5Cwm2c3PhDHVqrGUxrZ83Fm CGftfqvIMS7GwF9wWCDynSrZexPCERGkTIOuBrCFqxYHig==; 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:In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=cSkLwAxuxz5X1DHxwcEX2nFWmUy0nbag5jIziOLQP/s=; b=jXI4uv25wTmGlqjDaVOfRuyLvB Qj+bMvMTCPHJzFCbmR2RY9XEJV2JmBMN18o0rVrDOlHJsimwczDQzgzXUMsh7s3g/ioasuIpVwFRX //5gQ9uC7gPmj61t/1lMNApoSM+cb80x/n70ImkI9dkCrGkmk5wndNxdhnx/IwJ844Y+G2c6NxOCu BnkD1XftD7eE41xJxYYm4nHhGjLg5ZXO3JNH6f3Y4kWyXLN3vUCnO1aWVcwM0CBBXC3fBqDG2Gv9P Hmmw7yKdXY+dOCnaaAKjMo2cE28H1s9swfpBc2594hXoo7+nVLnm+NttVfmTYzsoZ//0ruz/auBgz rJcw30IA==; Received: from authenticated user by zero.zsh.org with local id 1lWJc3-0001Si-KP; Tue, 13 Apr 2021 14:01:55 +0000 Authentication-Results: zsh.org; iprev=pass (out2-smtp.messagingengine.com) smtp.remote-ip=66.111.4.26; 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 out2-smtp.messagingengine.com ([66.111.4.26]:46219) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_256_GCM_SHA384:256) id 1lWJbr-0001DD-7C; Tue, 13 Apr 2021 14:01:44 +0000 Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.nyi.internal (Postfix) with ESMTP id 593025C0032; Tue, 13 Apr 2021 10:01:42 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute3.internal (MEProxy); Tue, 13 Apr 2021 10:01:42 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= daniel.shahaf.name; h=date:from:to:cc:subject:message-id :references:mime-version:content-type:in-reply-to; s=fm3; bh=cSk LwAxuxz5X1DHxwcEX2nFWmUy0nbag5jIziOLQP/s=; b=TbC9yY9Pn0t7s+WDH6n GmHHkWCdyutflgJY/HR1RgKdZ8f7wBZlj+JUsFTt865u8WOhVPMmJ2Bjly2jZ6nG 6aeGmVPxSFjtDHymqnJCQUE5h3XRI9/HC3DjgseJ8/Nc/ZAjGGtCeY9ITym9iuZ+ 9emvvhLz9XCb8p43yYqM8KOAhq+3ZhT5m55vYFgg1j8wgwbtAOHfmg2V+CKLF2up do310oPaiLrjQMvSYYE3ZEpGdWrGQ+n67sLAPEs3JEu8zQefk/3tYIvL7dsgjZAn cvlXD+lvVyTR0ycuCzirQDi/vAE7/LIvVYgZOp1H8MN7I94wJMdHKS7d82sGurqe ixA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc: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=cSkLwA xuxz5X1DHxwcEX2nFWmUy0nbag5jIziOLQP/s=; b=JT2LeiscAWPosndg79fra+ hUzy67+u62Yg8KZrl9fLmhXWl7xHanfQteFMI7uynakXVv/Nwzq0duHgRHfoN9EB 1Tmu6dpzakVzXmNK3bEKvhbzJBRlqRzrP8LngTWLl5qxIUoozM77BwLdvPX6munc yiGjTgKYq/I1xsNzG1JtHwvNVfcQRH2PsIzwMViApa7aEfUa8y6uKwA5V/UGi4lt MiDCujwaPlx8u3EUfMAYoJe9VAUL+DdtO6o/SeSYJhub7KXWysuu0zrUwv/z0HzJ 49T6KmNaVuYPvakcmzospVFLC5eol0WmPQxPjYpjY/P8GHvBvvPdsLupF7urvyOA == X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrudekledgjeduucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpeffhffvuffkfhggtggujggfsehmtd dtredtredvnecuhfhrohhmpeffrghnihgvlhcuufhhrghhrghfuceougdrshesuggrnhhi vghlrdhshhgrhhgrfhdrnhgrmhgvqeenucggtffrrghtthgvrhhnpeejveeivdetgfehie ejfeettdejueetteduvdevudfggfelkefhffevueeufeelieenucffohhmrghinhepiihs hhdrohhrghenucfkphepuddtledrieeirdeifedrvdeftdenucevlhhushhtvghrufhiii gvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpegurdhssegurghnihgvlhdrshhhrghh rghfrdhnrghmvg X-ME-Proxy: Received: from tarpaulin.shahaf.local2 (bzq-109-66-63-230.red.bezeqint.net [109.66.63.230]) by mail.messagingengine.com (Postfix) with ESMTPA id C074024005A; Tue, 13 Apr 2021 10:01:41 -0400 (EDT) Received: by tarpaulin.shahaf.local2 (Postfix, from userid 1005) id 4FKS2W4ywvzhV; Tue, 13 Apr 2021 14:01:39 +0000 (UTC) Date: Tue, 13 Apr 2021 14:01:39 +0000 From: Daniel Shahaf To: Tim Lee Cc: Lawrence =?iso-8859-1?Q?Vel=E1zquez?= , zsh-workers@zsh.org Subject: Re: [PATCH] Improve vcs_info example for ahead/behind git commits Message-ID: <20210413140139.GK6819@tarpaulin.shahaf.local2> References: <20210328213628.7rwz62bq5p2isd6b@home-guest> <20210329070611.GM18178@tarpaulin.shahaf.local2> <20210329093056.fegqam75id4yfkiq@home-guest> <20210329103927.qzky3fyevptfflvj@home-guest> <1b0343d9-87c2-4a0d-860f-30a390d7034d@www.fastmail.com> <87d2c775-18f3-4664-9a3f-de62f5b71777@www.fastmail.com> <20210413113441.GD6819@tarpaulin.shahaf.local2> <20210413115830.5wogi3e7dh2tthmw@localhost> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="fUYQa+Pmc3FrFX/N" Content-Disposition: inline In-Reply-To: <20210413115830.5wogi3e7dh2tthmw@localhost> User-Agent: Mutt/1.10.1 (2018-07-13) X-Seq: 48528 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: --fUYQa+Pmc3FrFX/N Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Tim Lee wrote on Tue, Apr 13, 2021 at 19:58:30 +0800: > > Tim: Would you have time to address the remaining points from the > > original review, https://zsh.org/workers/48306, either by implementing > > them and sending a revised patch, or by counterarguing them? > > I think I'll just porpose something simple, since I'm not very familiar > with ZSH. > > Patch: Thanks, applied, and here's a patch series for implementing the other outstanding points. Would you review it, please? See anything that could go wrong, or that's missing? Cheers, Daniel --fUYQa+Pmc3FrFX/N Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="0001-vcs_info-git-docs-ahead-behind-commits-Don-t-run.patch.txt" >From 8a521515ce88802846df8884cabdd3966d0f32a8 Mon Sep 17 00:00:00 2001 From: Daniel Shahaf Date: Tue, 13 Apr 2021 13:56:36 +0000 Subject: [PATCH 1/2] vcs_info git docs: ahead/behind commits: Don't run rev-list when that would fail --- Misc/vcs_info-examples | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Misc/vcs_info-examples b/Misc/vcs_info-examples index d33d0ceed..065ea6cb3 100644 --- a/Misc/vcs_info-examples +++ b/Misc/vcs_info-examples @@ -179,6 +179,9 @@ function +vi-git-st() { local ahead behind local -a gitstatus + # Exit early in case the worktree is on a detached HEAD + git rev-parse ${hook_com[branch]}@{upstream} >/dev/null 2>&1 || return 0 + ahead=$(git rev-list --count ${hook_com[branch]}@{upstream}..HEAD 2>/dev/null) (( $ahead )) && gitstatus+=( "+${ahead}" ) --fUYQa+Pmc3FrFX/N Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="0002-vcs_info-git-docs-ahead-behind-commits-Reduce-th.patch.txt" >From d084af57318a98f5e3ff197e269f42611e5d2443 Mon Sep 17 00:00:00 2001 From: Daniel Shahaf Date: Tue, 13 Apr 2021 13:56:31 +0000 Subject: [PATCH 2/2] vcs_info git docs: ahead/behind commits: Reduce the number of forks --- Misc/vcs_info-examples | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/Misc/vcs_info-examples b/Misc/vcs_info-examples index 065ea6cb3..ba94cca29 100644 --- a/Misc/vcs_info-examples +++ b/Misc/vcs_info-examples @@ -182,10 +182,14 @@ function +vi-git-st() { # Exit early in case the worktree is on a detached HEAD git rev-parse ${hook_com[branch]}@{upstream} >/dev/null 2>&1 || return 0 - ahead=$(git rev-list --count ${hook_com[branch]}@{upstream}..HEAD 2>/dev/null) - (( $ahead )) && gitstatus+=( "+${ahead}" ) + local -a ahead_and_behind=( + $(git rev-list --left-right --count HEAD...${hook_com[branch]}@{upstream} 2>/dev/null) + ) - behind=$(git rev-list --count HEAD..${hook_com[branch]}@{upstream} 2>/dev/null) + ahead=${ahead_and_behind[1]} + behind=${ahead_and_behind[2]} + + (( $ahead )) && gitstatus+=( "+${ahead}" ) (( $behind )) && gitstatus+=( "-${behind}" ) hook_com[misc]+=${(j:/:)gitstatus} --fUYQa+Pmc3FrFX/N--