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 1761 invoked from network); 29 Mar 2021 11:51:06 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 29 Mar 2021 11:51:06 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20200801; t=1617018666; b=zKgsYxCS1iR/GBB/wYg1/y3uB/jrj8t6DR5of++I0/XxfUEzqtFxEbDKw1iWqygSYwwgiHwOt7 9BljcXqBn+JNSti5uUxM+5ZqHkwlicZPCZ7wWhRfOxt3Q8lriAka3Pvb4OZRi+D1fSMmpvHToA 82F2dw0WHnbNLfiWBni6Dep/1uamCs1rUYmqh+A1//LUOFkqMVTBmVITAC3B/sbNZWGCkBOQhJ +tcmMK962gXpVCtNI9LfDBt9DAzUbRIxCu2F4Vs/Bxhb4Ze+/UyLpEDrL1SMsTFBBp7KhFiVJn xgijcIeeHLSjFliFOe5pBpacVC2c4sw/5t7RqtmzvJEhbA==; 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=1617018666; bh=SF1X1c590UkxZFAT9EUPyyeVUQdeb/v9WSg8kB9sgIw=; 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=QD8F5fW8hl2f088HMi0Lg1hk/wVeRS2ZTzur/D4oXeeoHifpiux2ewAkeJAZBlKOb9cPMGW8Bm 2LAqwFrq+W3vzY5rWXeH4z0JYPbUqpM6UZo/PjJrgUvLvvvjPOAdrFBsgHIkNeq+Jo3VfvpoQc yqn9csmx+2ceJz85GdYBJ/X8DgOde3BgQFFFrHVWKP6dlnS44Z0XL24KkHVaU18hUq5kd6iJAW HAcUihuAiyqBvX8/4eddUtFxaJztkHwp9lkvZ9vdDAywCey2cres+W9FWA9W/HOYeFR3fXiGx5 PldlqZuQArwvXkP4LXeKQlmfwbD0HrsSBuSo+AZ1WoNZ+g==; 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=GIXzYtAn5AAxIDbi5VZcogwCq67ho5nZTi59bTdueno=; b=OVM3uG8/k6nabNBo07kacJA+oh NGRGTnlnOSqbbqwmVKltCG5x0p38ClMVtwsEE82NK8zQ1LuIqAhxq9Mjqg2S6Wy81TEtk6x1bITm7 486GBL9VtLgHjuWQ+p6gjg0iQGilqj3/N8EUIi0qX2ebN2wEFNRk2nSTosX/Z+vw1qpm702f7ZTBx dpvRpp3ufvECpMNdX2VLJZdd/DJZr67R3ChK6Zm2EYGLpj+ndpkTw+o2zAkC3/rGNf3FcDfwSZ60t 2E45wautyY5iaA7QKshG8RugNnQiSYUN4KzFR+L63zh8Y+BCaHIKRhkP+4NRRvDltzIChNtBgLrbl tE2Ht4pg==; Received: from authenticated user by zero.zsh.org with local id 1lQqQD-0001dn-5E; Mon, 29 Mar 2021 11:51:05 +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]:47713) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_256_GCM_SHA384:256) id 1lQqPx-0001Uq-RD; Mon, 29 Mar 2021 11:50:52 +0000 Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.nyi.internal (Postfix) with ESMTP id 95D3C5C00EB; Mon, 29 Mar 2021 07:50:48 -0400 (EDT) Received: from imap37 ([10.202.2.87]) by compute3.internal (MEProxy); Mon, 29 Mar 2021 07:50:48 -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=GIXzYtAn5AAxIDbi5VZcogwCq6 7ho5nZTi59bTdueno=; b=nXMVUhupG1SUb9C5TytKxrMxwuO0DhZ5xXnPMMwIM6 wffms5u9Ndfc1nejlUw1r6tyeRw+JfSlEZy5m7cVXrZNg48/otM6TQZU6NrTi4g6 +RGTtSHmNwEsdRm7UC/0lLfrpovwas6+/1G9aDO83CA0rq8dQT7slFGd8P6QsEVs x5XyfplLKkSCnODHHxVtsrC3oLKrxSNRkUGH3qa1dt/TvRtKUx0kDXDQWkJ5UvIC uZY4XVcY5/Oly9MpQ+d1Eou24qKg8TR/r/cpXVj0NJtLOEgjVxJgwAfJd5wax/JP k3aLkThJRmpvIEfIGpLsENKEZdQQ7ikESCMG2jth5pCw== 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=GIXzYtAn5AAxIDbi5VZcogwCq67ho5nZTi59bTdue no=; b=CyeroOCkub7G3qzu0/rOHglQ6FoQBdFSX2UIukqzA9D0dmQSGpTe9f2Yo 0MkrW73KgzhUbdP+4TwFNWR1T4RYNMtLO3GyHsGkV85RWA3VDsC9/mvocABE8lQg FBMS9sr+zhsYG0khSf3Z/z0eDqUOpQ6YVztG6cE12Fdk/xUiHs9eKAU5BmES6eF+ 2up1Ovg/+V32PSZTmx4PSn2ocd4qVkgIT0SJsN6koboOOBtumfLuDYBXVWWrAGLU 1m7OW6B6aNcSEqfwKDY6N6Ydmu/jYuZyVp+FRLUMpQhmJvdkkL0ciHWW1Soj0DZo ufJ1z5JRQE+gF12A1mlQdBKMOZEeQ== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrudehkedggeehucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefofgggkfgjfhffhffvufgtgfesth hqredtreerjeenucfhrhhomhepfdffrghnihgvlhcuufhhrghhrghffdcuoegurdhssegu rghnihgvlhdrshhhrghhrghfrdhnrghmvgeqnecuggftrfgrthhtvghrnhepfefhkeefve eileelheeiffdtkedujeelvdfhtdejtdeggedvuefffeelhefhvdfgnecuvehluhhsthgv rhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepugdrshesuggrnhhivghlrd hshhgrhhgrfhdrnhgrmhgv X-ME-Proxy: Received: by mailuser.nyi.internal (Postfix, from userid 501) id 3C86B6B40061; Mon, 29 Mar 2021 07:50:48 -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: <1b0343d9-87c2-4a0d-860f-30a390d7034d@www.fastmail.com> In-Reply-To: <20210329103927.qzky3fyevptfflvj@home-guest> References: <20210328213628.7rwz62bq5p2isd6b@home-guest> <20210329070611.GM18178@tarpaulin.shahaf.local2> <20210329093056.fegqam75id4yfkiq@home-guest> <20210329103927.qzky3fyevptfflvj@home-guest> Date: Mon, 29 Mar 2021 11:50:17 +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: 48315 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 10:39 +00:00: > > > > > 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= | wc -l) > > > > > - ahead=3D$(git rev-list ${hook_com[branch]}@{upstream}..HE= AD 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/n= ull) > > > > > (( $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...@{= upstream} ) ) > > >=20 > > > The snippet below displays N/M. How would you make it display +N/-= M > > > instead? > >=20 > > Change the last line to hook_com[misc]=3D"+${x[1]} -${x[2]}". >=20 > But hook_com[misc]=3D"+${x[1]} -${x[2]}" would display a '+0' and/or '= -0' > when the local git branch is not ahead-of or behind the remote branch.= >=20 > The existing example does not display '+0' or '-0'. You didn't specify this when you asked. Anyway, if you want not to show= +0 or -0, then add the appropriate logic =E2=80=94 e.g., =C2=ABif (( x[2= ] )); then=C2=BB. We're on -workers@ so I thought that'd go without saying. A bit further out along the "readable"=E2=80=93"line noise" spectrum the= re is this alternative: hook_com[misc]=3D"+$x[1]/-$x[2]" hook_com[misc]=3D${${hook_com[misc]#'+0/'}%'/-0'} Cheers, Daniel