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.3 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 2435 invoked from network); 8 Dec 2022 14:58:06 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 8 Dec 2022 14:58:06 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1670511486; b=TQIXbyu3rREorbfST2iwu3MODU4RftbjxjrH+YqVuuA9JjDvcZFsRT9ogWcJ/E7xrhk3VNxccS GNLFVI1ux3oB0TWw+81M6eD9AwfyscRPK/ZRIGaf68g6WGGzwtvNXNncDtfhVDyCFZbTRYaKpL WKJz45a4FkxhzrnVUfkNKc2RaYJdYWj55rxVmO7MXjv9oOX9NqrCC4vXg8cRQOReorhZHjmmLk KraFqJNEno6c9PhZffdbrWWTr0lPpszsU9RyhdIw10BfFW4jSr7Zv3dCxSkcxC5egBG/PJgR32 OLPmCL6Qdp16ApSJU8Orfp9w3iro60Sl6iDhTMsRblQXhA==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (out5-smtp.messagingengine.com) smtp.remote-ip=66.111.4.29; dkim=pass header.d=jpgrayson.net header.s=fm1 header.a=rsa-sha256; dkim=pass header.d=messagingengine.com header.s=fm2 header.a=rsa-sha256; dmarc=none header.from=jpgrayson.net; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20210803; t=1670511486; bh=1IZibJCkOt7jFerWk9NVzKtnhVqTuOtMBxp2u5+ExBU=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Content-Transfer-Encoding:MIME-Version:References: In-Reply-To:Message-ID:Date:Subject:Cc:To:From:DKIM-Signature: DKIM-Signature:DKIM-Signature; b=JLPJ4epBWRR9ijreZ9VQymTHe4EA9l8jYijOxZqDov0coayRZgLrzrAfnIGdavjDiu2p/CWyvY OUrX1NcAFLNs8obwHYbu3Nr413iHnm/ibCXJyInqM8COsqBQEit8qeFTFZCqKoQPx02sx7xXjz +liFSaqp/mdwmG0DUKZB/24aG1AWTGSKg+Z2VU+whUec6b+Ha2sqQPHEYsPDH/XfW850XMIwVH WZS4L1iVjWGu0KOgcjwxE4InIG+xCW94RBkmF0Bqb0/vofbjECLmzWqQZIUdVjjZosIFjn6PbH NFIBBz4Z1x/Ci31sm/XVQUN8D15iJB48bNOocNA/tFWAHQ==; 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-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=KdvuBFNgbzfUIuE5IKHrMrkrhWEjntQzdPIcvYdsuSA=; b=Su5MqyVFwEXPyT2IwZu155mXs1 pgCWwPP3duf3+lDKcA4FsoIiiPoUY6/hbq7ICYkNeXPh232IfqHQidq/bN3Y1vqgY8iWeaK26lcET OJjpxwA8Hkv5VIYSQvR4L2GO8OEPHrBKp86dHYEDba99iUibvckiLElVLmVgUFptKIh8rawHHgSgR Pms2a2Plv74dMQY6JSX1q2LYKUTTpTHjv4vGdYhlqrbPGlbB/l1cQRmXQQwQJSgCMxuRkQqF4kFVq btMgAvb8sJgPWwvXl5NAiNkAgZHQVfqhN3yibxvnIZgg57EqW6fmuoNjheTC/Hs51UlvrhzyOwsuI dl67FJGA==; Received: by zero.zsh.org with local id 1p3ILc-000ICO-CJ; Thu, 08 Dec 2022 14:58:04 +0000 Authentication-Results: zsh.org; iprev=pass (out5-smtp.messagingengine.com) smtp.remote-ip=66.111.4.29; dkim=pass header.d=jpgrayson.net header.s=fm1 header.a=rsa-sha256; dkim=pass header.d=messagingengine.com header.s=fm2 header.a=rsa-sha256; dmarc=none header.from=jpgrayson.net; arc=none Received: from out5-smtp.messagingengine.com ([66.111.4.29]:57133) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_256_GCM_SHA384:256) id 1p3IL1-000Hsq-Nz; Thu, 08 Dec 2022 14:57:29 +0000 Received: from compute6.internal (compute6.nyi.internal [10.202.2.47]) by mailout.nyi.internal (Postfix) with ESMTP id BC1825C0172; Thu, 8 Dec 2022 09:57:24 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute6.internal (MEProxy); Thu, 08 Dec 2022 09:57:24 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jpgrayson.net; h=cc:cc:content-transfer-encoding:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to; s=fm1; t=1670511444; x= 1670597844; bh=KdvuBFNgbzfUIuE5IKHrMrkrhWEjntQzdPIcvYdsuSA=; b=n ZFJ85+0GCzyOOB9GDdTpd79LzMruKtRSZrg1SJU+qc5NbBX2zinug3liHXBJ7TCm UURN9aVLzFyOaN2NIa7KprPg8rHQCKjkhnXsPBEasRf4osKtEqXbwm7ETp7oxXxN NXSEaeg1B4RSmN3VEMC9fxE9wt6vo6CmDbIAT/Eer5XZ2fe3XH8CP9GDeIv6RbsQ CYKYztDcKmtCWsSw0/p+WT5NrlEcqpyRwr8y2NVaQCJITGHrC8S2HafTu/Sk3N/f Msye1F4naNs3SCPUXbMPuFlWsjVv0gsulrcGjPGaJo3BHayB+Ff1Zhwvju0arYhp w5mSw7CM5MhMcc2Q8lEFA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:sender:subject :subject:to:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm2; t=1670511444; x=1670597844; bh=KdvuBFNgbzfUI uE5IKHrMrkrhWEjntQzdPIcvYdsuSA=; b=pZin3L1I5TTH/YMA++pb38TZBUwWy 79XNIpC0RUWpMbXGkZTN5bLruNB+c9GMziAMxiMIGxK0nJhW47EsapBIAIBbDlZG E9QZy3HkosBNp9xysqfo/j2mPxxglLYGBT3UIx2OdzqCfz2N4r9Z6dwoZQmjhxOo 7dhcOwHzxs0aMwlLl2vAvjwHupL3GcvK4Af2i6Q364QPS5wZzO3jVO87TG07mrMg PH6No88hk3x2a1Yx5ItXK+NJK6KgrCCMBAx53utOeS73fWzh8rXstduRVsnzqsxX cNoSTNYeQavHa7efp2lxLW3uOexTyNSH+cJ5mTVvC2ifU4nGdJx2tJ3EA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrvddtgdejudcutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecunecujfgurhephffvvefufffkofgjfhgggfestdekre dtredttdenucfhrhhomheprfgvthgvrhcuifhrrgihshhonhcuoehpvghtvgesjhhpghhr rgihshhonhdrnhgvtheqnecuggftrfgrthhtvghrnhepgeetudeggfejvdehkedugfeuge evvddvfefhjeetfeegveeiheevuddugefhfedvnecuvehluhhsthgvrhfuihiivgeptden ucfrrghrrghmpehmrghilhhfrhhomhepphgvthgvsehjphhgrhgrhihsohhnrdhnvght X-ME-Proxy: Feedback-ID: iefe944c0:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 8 Dec 2022 09:57:24 -0500 (EST) From: Peter Grayson To: zsh-workers@zsh.org Cc: d.s@daniel.shahaf.name, Peter Grayson Subject: [PATCH v3] Updated StGit patch detection in vcs_info Date: Thu, 8 Dec 2022 09:52:42 -0500 Message-Id: <20221208145241.494978-1-pete@jpgrayson.net> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221116204501.921232-1-pete@jpgrayson.net> References: <20221116204501.921232-1-pete@jpgrayson.net> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Seq: 51138 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: The vcs_info patch detection code attempted to interrogate StGit patch stack state by inspecting .git/patches/applied and .git/patches/unapplied. As of StGit 0.15 (2009), patch stack metadata is captured in the repo's object database. And as of StGit 1.0 (2021), no stack or patch state is maintained in any files in the .git/ directory. Zsh's approach for interrogating StGit patch state is thus obsoleted. This patch updates vcs_info to determine whether StGit is initialized on a branch by looking at the appropriate git refs and uses StGit's prescribed interface for interrogating applied and unapplied patch state via the `stg series` command. This approach will work with all versions of StGit >=0.15. Signed-off-by: Peter Grayson --- This is a slight improvement over the v2 patch. Only a single `git show-ref` is used to determine whether a StGit stack is present on the current branch instead of one or tow `git rev-parse` calls. I recommend applying this patch. It solves the StGit compatibility problems in vcs_info: - Works for all versions of StGit going back to 2009. - Does not impose runtime overhead when `stg` is not installed. - Only imposes the small cost of `git show-ref` (<0.5ms) otherwise. - Small patch. Low risk. .../VCS_Info/Backends/VCS_INFO_get_data_git | 36 ++++++++++++++----- 1 file changed, 27 insertions(+), 9 deletions(-) diff --git a/Functions/VCS_Info/Backends/VCS_INFO_get_data_git b/Functions/VCS_Info/Backends/VCS_INFO_get_data_git index e45eebc8e..23d4d31a1 100644 --- a/Functions/VCS_Info/Backends/VCS_INFO_get_data_git +++ b/Functions/VCS_Info/Backends/VCS_INFO_get_data_git @@ -184,15 +184,8 @@ fi VCS_INFO_adjust VCS_INFO_git_getaction ${gitdir} -local patchdir=${gitdir}/patches/${gitbranch} -if [[ -d $patchdir ]] && [[ -f $patchdir/applied ]] \ - && [[ -f $patchdir/unapplied ]] -then - # stgit - git_patches_applied=(${(f)"$(< "${patchdir}/applied")"}) - git_patches_unapplied=(${(f)"$(< "${patchdir}/unapplied")"}) - VCS_INFO_git_handle_patches -elif [[ -d "${gitdir}/rebase-merge" ]]; then +local patchdir +if [[ -d "${gitdir}/rebase-merge" ]]; then # 'git rebase -i' patchdir="${gitdir}/rebase-merge" local p @@ -389,6 +382,31 @@ elif [[ -f "${gitdir}/CHERRY_PICK_HEAD" ]]; then git_patches_unapplied=() fi VCS_INFO_git_handle_patches +elif command -v stg >/dev/null && + ${vcs_comm[cmd]} show-ref --quiet refs/stacks/${gitbranch} refs/heads/${gitbranch}.stgit 2>/dev/null && + git_patches_applied=(${(f)"$(stg series --noprefix --applied 2>/dev/null)"}) +then + # Testing for StGit patches is done after testing for all git-proper + # patches/states. If a StGit user's repo is in one of those states, they + # will want to see that instead of the StGit patch info. + + # Performance note: testing for the stg executable is done first because it + # is extremely cheap and there is nothing else to do if it isn't present. + # Using git to test whether a StGit stack is initialized is cheaper than + # running stg itself; especially for versions of StGit <= 2.0. Thus getting + # StGit patch info should only have a material runtime cost if StGit is + # installed and in-use for the current branch. + + # In StGit >=1.2, the existence of refs/stacks/ indicates StGit is + # initialized. In StGit >=0.15, it is refs/heads/.stgit. + + # N.B. the "--noprefix" option is available in StGit 2.x as an alias for + # --no-prefix. The former is compatible with StGit versions going back to + # 2008. + if zstyle -t ":vcs_info:${vcs}:${usercontext}:${rrn}" get-unapplied; then + git_patches_unapplied=(${(f)"$(stg series --noprefix --unapplied 2>/dev/null)"}) + fi + VCS_INFO_git_handle_patches else gitmisc='' fi -- 2.38.1