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 7867 invoked from network); 16 Nov 2022 20:52:56 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 16 Nov 2022 20:52:56 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1668631976; b=TmZRDSXpv+m5A5S+ctoeTMBVcjZX0ktZLWZHa2tQ8ZNFwUtZy2up/Xgll4bMol5s0uT/aLiiRx kE8m8XKIyYs729d1vsPKeJyd8wa8CUuIoTRQ465c7Czmc7FZBFx8DYA35WKM0AfG8y5sR3Wd4K fHGrGS02Hy4XQOJ0w0s6aqWMmLmlWlDPUO8VxR+XiTk6rCju2mZ4tIECc4SsL1XQ3/9QJI/yMn VQRnQkDBDh/3A5UNsMJWTqhFPr/26CGfvb7zp/CGEgfGQL8ML7VP3sPtAXl9U03s69q+Il4J63 K0g8hPbzQe4Ac4hd7HxSB/JkubAJxDlYE363l7BslSkD7g==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (wout3-smtp.messagingengine.com) smtp.remote-ip=64.147.123.19; dkim=pass header.d=jpgrayson.net header.s=fm3 header.a=rsa-sha256; dkim=pass header.d=messagingengine.com header.s=fm1 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=1668631976; bh=5h0FZeP2BgQHRtfUO2/wHn6d6KwgJS9CTyfDbZsgBzY=; 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=MXraCEcc0Ofm3vNQL/l5WuTx3/+wKPIc0ovuT5iBYSx83Vh/YLOFpXib4Z+0ED9pxpbIpaHpRC I40urug2k5MEnhcWc/5T/HyVzqmGiN+cAJzBzPsyeYDiuGHhZio8XBHAAtsAonHLA4D53tHU9j 20Q9j7YHX8t177pypq/YS/2/AqWh9rlRZo9HbKNCqXrS2oIBV6v3S7L/jeIpmJNDPQAIQTDw78 kCKJPcNNNE0SP5SsooXFFxnOIhODcvuocAWlVumcnTE2sbAj+OQWppHSVf/jximTbvfiu8suE7 92m31K/p8YRfn2KVJkA0jv/F9Se6c32ABSxWAC1ISZVxLg==; 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=EsW2BisZ5UTGFPk6cx9n61G15DihrzDnAJIAeDpsBE0=; b=lfsn+hWbNHcxI4iYU4qzDRvIhZ B4AWR29FKSbPtbIk/aaabzZug9nzJ/V5uTKzpILKGr4L9WnoBwGN4Q3ciwMhhybs2b4z/x0weiHZg iNFIgyBr46jWoviqTxiCkEkWzjb7Q8DMUuyceE2kMTc71jwBhWPMRckOVN3g4cE8rmLnm3vUD8QN5 S5+4zaMicTfxPnMsI0ezH+x/IKN4tQaXeu5ta1P9JBMqoXvVRCLkiUA/bHq/xCmRErcyDFUt6tTla X6FLnALHXzJZXUiFRV3BMY6Wxz6bFkpv9huccc34Kt8Fo+n2ikqM+x5e2y3zoxsA7SvvOUcvOvCTK 3LnhfVwQ==; Received: by zero.zsh.org with local id 1ovPOx-0004Iy-HW; Wed, 16 Nov 2022 20:52:55 +0000 Authentication-Results: zsh.org; iprev=pass (wout3-smtp.messagingengine.com) smtp.remote-ip=64.147.123.19; dkim=pass header.d=jpgrayson.net header.s=fm3 header.a=rsa-sha256; dkim=pass header.d=messagingengine.com header.s=fm1 header.a=rsa-sha256; dmarc=none header.from=jpgrayson.net; arc=none Received: from wout3-smtp.messagingengine.com ([64.147.123.19]:60463) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_256_GCM_SHA384:256) id 1ovPIW-0002gB-R1; Wed, 16 Nov 2022 20:46:18 +0000 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.west.internal (Postfix) with ESMTP id EFB193200406; Wed, 16 Nov 2022 15:46:11 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Wed, 16 Nov 2022 15:46:12 -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=fm3; t=1668631571; x= 1668717971; bh=EsW2BisZ5UTGFPk6cx9n61G15DihrzDnAJIAeDpsBE0=; b=m hvTRsgD2dw1iml8bSnFRbfz+sQ3mAbvWJ+fGMGt9sjcDHBY+RzVpWMzDHG+jDkLK 4d+1uVnFCtXJR1RDrHQHN0onLxzDH/MLwD9JDpXmFKdetJlZRv/wBItvUqowJSuH 4Hjmjyq6ESRrQxSmt0L/pd0KxcvHP1yGW3XyIpKOp6gEQTguKe+OuaPjUvyIXRe2 /WQ6fnDaK85GsxdZaxgjidjCbDoT55PgiU0YkHt9+JedF/1f6/prwiAiT46c8d5p tJO/EdJI1xLcpXvgf9McxbdP/MGpTVxM+A5ku0E7Me92Z699+r7q35Ajt39/QcS6 0F3ZkgTDn0cUVNpx6CB8A== 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=fm1; t=1668631571; x=1668717971; bh=EsW2BisZ5UTGF Pk6cx9n61G15DihrzDnAJIAeDpsBE0=; b=Q0Qi//MWiucwX3pk5cQ46kzxqoP3J G8IpoYDkv8ecVtoCp5wrMBsJyR6L7A5nCcW9CA59SMMBvA/eoPKHleksODgMwbml 0FKQ2uAa17tzJbUjsKqT3Bx7wF7Q9id7hgSIGFGM+sOGNAGfCTJZIutC7vf+Mqur Uu6ymwAP+MmY0+eDtVznWha34mhoDt9boMW2/FBBQYfEVKwukzs+Ycjsz90G1AkW WTGnFug/5TuTrhYssGYl0jZ6ZOLJ3ke4PSnGdfXsNp1qQLkzXypfKjYqBuzbP0HU ZRQwR4XVNvOmFKSUjyydYq3app+Aqktj6XAlmmxHN+C8WTl6xKN5Z4Nog== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvgedrgeeigddufeelucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefhvfevufffkffojghfggfgsedtke ertdertddtnecuhfhrohhmpefrvghtvghrucfirhgrhihsohhnuceophgvthgvsehjphhg rhgrhihsohhnrdhnvghtqeenucggtffrrghtthgvrhhnpeegtedugefgjedvheekudfgue egvedvvdefhfejteefgeevieehveduudeghfefvdenucevlhhushhtvghrufhiiigvpedt necurfgrrhgrmhepmhgrihhlfhhrohhmpehpvghtvgesjhhpghhrrgihshhonhdrnhgvth X-ME-Proxy: Feedback-ID: iefe944c0:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 16 Nov 2022 15:46:10 -0500 (EST) From: Peter Grayson To: zsh-workers@zsh.org Cc: d.s@daniel.shahaf.name, Peter Grayson Subject: [PATCH v2] Updated StGit patch detection in vcs_info Date: Wed, 16 Nov 2022 15:45:02 -0500 Message-Id: <20221116204501.921232-1-pete@jpgrayson.net> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221112154221.661029-1-pete@jpgrayson.net> References: <20221112154221.661029-1-pete@jpgrayson.net> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Seq: 50984 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 --- .../VCS_Info/Backends/VCS_INFO_get_data_git | 38 ++++++++++++++----- 1 file changed, 29 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..e275abbb2 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,33 @@ 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]} rev-parse --quiet --verify refs/stacks/${gitbranch} >/dev/null || + ${vcs_comm[cmd]} rev-parse --quiet --verify refs/heads/${gitbranch}.stgit >/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