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, T_SCC_BODY_TEXT_LINE,UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 5246 invoked from network); 13 Apr 2022 05:38:59 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 13 Apr 2022 05:38:59 -0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=zsh.org; s=rsa-20210803; h=List-Archive:List-Owner:List-Post:List-Unsubscribe: List-Subscribe:List-Help:List-Id:Sender:Content-Type:Subject:Cc:To:From:Date: References:In-Reply-To:Message-Id:Mime-Version:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=+k1Hmw9U/fDNAx7tilcpvksXuQEIa9ueMKn5Drukg98=; b=A2Wa1R6LEGHcoyHioT0ZWJ3UUE dobNQnC5H+wlLWnFc9l/pWIm451eGgZGx2Bub2dfXhf1rM7MPhDvWtaDOdG5MLjAzOPKVYUl1SnYo F5q1XDyKT4d+x3ra6iGhXr4tHMcTT1ed/IfIrwKaUQG0e3rSdznve5DGOB3EqPjLasxwGwekv2Tn8 wJmKgnX/p0tXtpBtc4VlV3Pm1/aN7m9BOleKKIT4KngoTis8DaMVusBFMhSCA70VtEcKNPS7f/qG4 hgS6fvI+YzGC8+ddDzic/tCGIdNwm7SYbwkYwSVBQxZv/EX56AdWwlMOdPi+gYQPrPDkWtb4bThO9 V2brgSrQ==; Received: from authenticated user by zero.zsh.org with local id 1neViV-000HNa-9M; Wed, 13 Apr 2022 05:38:59 +0000 Received: from authenticated user by zero.zsh.org with esmtpsa (TLS1.3:TLS_AES_256_GCM_SHA384:256) id 1neViA-000H2l-PZ; Wed, 13 Apr 2022 05:38:39 +0000 Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailauth.nyi.internal (Postfix) with ESMTP id 3285927C0054; Wed, 13 Apr 2022 01:38:37 -0400 (EDT) Received: from imap48 ([10.202.2.98]) by compute2.internal (MEProxy); Wed, 13 Apr 2022 01:38:37 -0400 X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvvddrudekledgleekucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepofgfggfkjghffffhvffutgesthdtredtreerjeenucfhrhhomhepnfgrfihr vghntggvpgggvghljoiiqhhuvgiiuceolhgrrhhrhihvseiishhhrdhorhhgqeenucggtf frrghtthgvrhhnpeeikeejveeludegfeeigfeulefggfdttdegheevvdehvdeigfehvdff uedvvdeuheenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhroh hmpehlrghrrhihvhdomhgvshhmthhprghuthhhphgvrhhsohhnrghlihhthidqudduhedu keejjedtgedqudduledvjeefkeehqdhlrghrrhihvheppeiishhhrdhorhhgsehfrghsth hmrghilhdrtghomh X-ME-Proxy: Received: by mailuser.nyi.internal (Postfix, from userid 501) id E0CAB21E006E; Wed, 13 Apr 2022 01:38:36 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.7.0-alpha0-386-g4174665229-fm-20220406.001-g41746652 Mime-Version: 1.0 Message-Id: <58222599-b634-401b-b70f-3e5fd5633839@www.fastmail.com> In-Reply-To: References: Date: Wed, 13 Apr 2022 01:38:16 -0400 From: =?UTF-8?Q?Lawrence_Vel=C3=A1zquez?= To: "Sam Bostock" Cc: zsh-workers@zsh.org Subject: Re: [PATCH] Abbreviate commit hash in prompt during git rebase Content-Type: text/plain X-Seq: 50054 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: Hi Sam, On Wed, Apr 13, 2022, at 12:41 AM, Sam Bostock wrote: > First time contributor here Welcome! > diff --git a/Functions/VCS_Info/Backends/VCS_INFO_get_data_git > b/Functions/VCS_Info/Backends/VCS_INFO_get_data_git > index e45eebc8e..dd9c40ab4 100644 > --- a/Functions/VCS_Info/Backends/VCS_INFO_get_data_git > +++ b/Functions/VCS_Info/Backends/VCS_INFO_get_data_git > @@ -209,27 +209,15 @@ elif [[ -d "${gitdir}/rebase-merge" ]]; then > return 0 > ;; > (''(p|pick|e|edit|r|reword|f|fixup|s|squash)' '*) > - # The line is of the form "pick $hash $subject". > - # Just strip the verb and we're good to go. > - p=${p#* } > + # Typically, the line is of the form "pick $longhash > $subject\n". > # Special case: in an interactive rebase, if the user > wrote "p $shorthash\n" > # in the editor (without a description after the > hash), then the .../done > # file will contain "p $longhash $shorthash\n" (git > 2.11.0) or "pick $longhash\n" > # (git 2.19.0). > - if [[ $p != *\ * ]]; then > - # The line is of the form "pick $longhash\n" > - # > - # Mark the log message subject as unknown. > - # TODO: Can we performantly obtain the subject? > - p+=" ?" > - elif (( ${#${p//[^ ]}} == 1 )) && [[ ${p%% *} == ${p#* > }* ]]; then > - # The line is of the form "p $longhash > $shorthash\n" > - # > - # The shorthash is superfluous, so discard it, > and mark > - # the log message subject as unknown. > - # TODO: Can we performantly obtain the subject? > - p="${p%% *} ?" > - fi > + # Given we don't reliably have the subject, and the > full hash is needlessly long > + # for a prompt, we simply extract the hash (second > word) and delegate to git to > + # format it as "$shorthash $subject" according to > git's hash abbreviation config. > + p=$(${vcs_comm[cmd]} log -1 --pretty=format:'%h %s' > $p[(w)2]) > ;; > (''(x|exec) *) > # The line is of the form 'exec foo bar baz' where > 'foo bar It strikes me as a regression to run git if we already have the subject; vcs_info is slow enough as it is. Could this be reserved for the edge cases where we don't have the subject? (This would preclude what is arguably your primary goal, which is using core.abbrev to choose between short and long hashes. But that amounts to using git as a glorified string slicer. Perhaps the choice could be determined by a style instead, and we could do the truncation ourselves?) -- vq