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 3098 invoked from network); 29 Mar 2021 16:56:57 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 29 Mar 2021 16:56:57 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20200801; t=1617037017; b=bk2z1aDeg0mmG1ltleFbeUvMhvgD+Do7PqgCmyLegKMmnFDg+1dZab1eCMrr3gBT4sZvpzdMKI KxJ52ZgqF3ZMyVflBCpDw/Lae4CTtaIt3R2eHT6bbaxOlmaqSJDo520OyGFfuPGhv2ceDaJq2H Q3DaiHzgAFs40SkKk2O2HCq8GuQwuf70tYDs80FEkjLkVEiO0ojxhrHxjSMurxo+5ibRkjwEzv bJwsznaVIc9vVOtLFJHU8In4HM6j1qY8nXYn6ui2EvI6+Dn+WPBH7RJXkyS9kBocDvsZL6OcEf jkGFo2gQVRCY9TWpkGRu/zTc3YxhSgTQl056ku1JajZPzw==; 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=1617037017; bh=Sc5To/xVkRGmhyIR13Z8OKyQfsbfz5tSuFtIsPjOvAY=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:In-Reply-To:Content-Transfer-Encoding:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:DKIM-Signature: DKIM-Signature:DKIM-Signature; b=f+wLryFM9QTxgy3SB8+HSU3A1FnM2DTyF0swo1Ho/czyBlWSH38q6L5Coyj4q748PCMefrMGMb M6y7D3Cgz7FYOWcevNhkcGvGA8IFUDQegwAa8ZTbiiU3U6/sKwCdIu+X4GuGfw3H9Om5X82uXA xdyekT38TJ/yFQ9vYaUUAOV/nBcMP3rtisMlpDJc0U6R6duiU0rgtwY8fnTuZZlK/Ny8/yhttD i9rJXDzJeO02eQrZW2abxSMhHb2MYWK9Iu4TKx1FroSP1oKcGYjJIoLv3xqBZMAdkAHoXK9QjA 3RttFRmYD2trgxjbpNFXqsbrQgSNnPvFO2NN0uESsrUPEQ==; 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-Transfer-Encoding :Content-Type:MIME-Version:References:Message-ID:Subject:Cc:To:From:Date: Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender :Resent-To:Resent-Cc:Resent-Message-ID; bh=9tqcFzT/gU+I40r1nry0rIJjeEF3BkQQ+B/X4zWuyb0=; b=EFiE331kXk4k3oxso1mzzthuaE BbZ5Xd/zsDm8XHKwZijOF2yMJ17cKKNX5oLSzbSYa7TZjdIoLb4yBBBkM6K6D8WYJfrnGAiYWIMvU CbuFAOVKUvm0vSLk+smkzXgz09ddstzuMzP+0/sBiePd83YV10ZevYJ2vIbQqdKlWSlbiKQ61ZxFY AhWnWplytOfL1qba2niMfesjQJbQTxUa61JIal0gkVHizelnjVYb2o3ai8Fc+/e+9eo/GtJq+oU3r Bk9B0rxB90ZUdSPNZjC8ANtesWQfZzqhDvxpVegzHbygfQ5pqkUhcD93pvGDWD9LPlyP/Hkiafg4g TZvYejkA==; Received: from authenticated user by zero.zsh.org with local id 1lQvC9-000C95-9u; Mon, 29 Mar 2021 16:56:53 +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]:33301) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_256_GCM_SHA384:256) id 1lQvBq-000C08-9N; Mon, 29 Mar 2021 16:56:34 +0000 Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.nyi.internal (Postfix) with ESMTP id E6DFC5C0106; Mon, 29 Mar 2021 12:56:32 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute3.internal (MEProxy); Mon, 29 Mar 2021 12:56:32 -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:content-transfer-encoding :in-reply-to; s=fm3; bh=9tqcFzT/gU+I40r1nry0rIJjeEF3BkQQ+B/X4zWu yb0=; b=RzeAOKLzZCaiX7lBp+2yf7w5QWg6B9fdRAlLncnFyz7yNbZNKHqDRwsH mW55Hkq2QZFdXdA0jIF+30W5BoCV+Jx1WwJZTkkVjJbOpakg4v0f5kTpNugi7QPH ZA9LjS8GCavMvE+lws1HuHXMBVNx/rkFT4GQ9CcaSd6ZQ9FoO+oTAlISG/w9qGMg wyLghGwhbf/A3s1TX5I8+lw3LZDN8MdMUeD3AVopsthrIktYd09adRLnslXXbned 745+n3a2fR/0yigKki3XsginN1pUqIqejejwCm+tocIXkSgznHD29Clm2Og2DPNH PpbbpzJYrQppxCJIQ0fNxuyDXvk3mQ== 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=9tqcFzT/gU+I40r1nry0rIJjeEF3BkQQ+B/X4zWuy b0=; b=go4pVlMzGi6CW9hOMQQhAKKKRlVlEDa0cZ/H/QMCfRLASyyiPV2WZ+LQl FNinSun7DC7xN9U+zN65VLU+iSRNs4OlM4IemWShHaVV+QnjIG9NQvkILCuFHdMP I8hFlYQ/aq94CuL2hHPMSKAsrLHAZ7AWRYWDaOVsQm494VsrmhxwQMDX4Ui7PuGe 2K8L9vvw9n7FgGHuHYFaZEGLRhFdXn5weeRL4aSUhmBv2UXkWclcmx11hhN8xNrx cBLzKCrJ8CRNnsZEUFxDGq6EpYDwbapdat3+h2g7TaN6x43WbwAWntciSVp8JCg2 lg8/jGktu/VD6YyMOH0UKOBtSQ76A== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrudehkedguddtkecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpeffhffvuffkfhggtggugfgjfgesthektddttderudenucfhrhhomhepffgr nhhivghlucfuhhgrhhgrfhcuoegurdhssegurghnihgvlhdrshhhrghhrghfrdhnrghmvg eqnecuggftrfgrthhtvghrnhepgfelhedtffeuhfegueelfeffjeegtddtleehvddvueei hfevgfdvgffhvedvkeetnecukfhppeejledrudekvddrfeeirddukedunecuvehluhhsth gvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepugdrshesuggrnhhivghl rdhshhgrhhgrfhdrnhgrmhgv X-ME-Proxy: Received: from tarpaulin.shahaf.local2 (bzq-79-182-36-181.red.bezeqint.net [79.182.36.181]) by mail.messagingengine.com (Postfix) with ESMTPA id 80B361080069; Mon, 29 Mar 2021 12:56:32 -0400 (EDT) Received: by tarpaulin.shahaf.local2 (Postfix, from userid 1005) id 4F8Jd92rFQz4Fv; Mon, 29 Mar 2021 16:56:29 +0000 (UTC) Date: Mon, 29 Mar 2021 16:56:29 +0000 From: Daniel Shahaf To: Aleksandr Mezin Cc: zsh-workers@zsh.org Subject: Re: [PATCH v4] vcs_info: choose backend by basedir Message-ID: <20210329165629.GA2761@tarpaulin.shahaf.local2> References: <20201114193703.1428617-1-mezin.alexander@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20201114193703.1428617-1-mezin.alexander@gmail.com> User-Agent: Mutt/1.10.1 (2018-07-13) X-Seq: 48329 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: Let me first summarize the previous threads: - The current default is that backends are used in order of the «enable» style: first detected, wins. - Frank prefers this remain the default. (workers/47488, workers/47509) - Aleksandr implemented a mode in which the backend whose worktree root directory is closest to $PWD would be used. - Bart's use-case (workers/44931) wouldn't be served by choosing the "deepest" worktree but by choosing whichever one has local mods. (workers/47490) - It was proposed to address Bart's use-case by calling vcs_info twice with different user-context strings and corresponding zstyle settings. - Oliver proposed some independent improvements in workers/47492. If any of that is inaccurate, speak up. The named people are Bcc'd. The patch being replied to contained some git- and cvs-specific changes which have been committed. Aleksandr expressed concerns about those in workers/44929, but as far as I can see, the part that has been committed is a no-op, other than the fact that vcs_comm[basedir] will be populated earlier. So, first things first: Does implementing a "choose the VCS whose root is deepest" mode that's off by default sound like a reasonable way forward? Any concerns with that? Any concerns with the algorithm described in Aleksandr's log message (just the log message, independently of the unidiff)? Below a couple of review points on my account. Not a full review; just what I spotted from reading the diff. Aleksandr Mezin wrote on Sun, Nov 15, 2020 at 01:37:03 +0600: > Previously, vcs_info iterated over enabled VCS backends and output repository > status from the first backend that works (i.e. first backend that can find a > repository). > > But I prefer a different behavior: I want to see the status of the repository > closest to the current working directory. For example: if there is a Mercurial > repository inside a Git repository, and I 'cd' into the Mercurial repository, > I want to see the status of Mercurial repo, even if 'git' comes before 'hg' in > the 'enable' list. > > This patch adds a new algorithm for vcs_info to choose the backend: > > 1. Among backends whose basedir isn't an ancestor of the current directory, > old algorithm is used: whichever comes first in 'enable' list. > > 2. If all backends return basedirs that are ancestors of the current directory, > the one with basedir closest to the current directory is chosen. > > As far as I know, unless the user has set basedir manually (GIT_WORK_TREE), > all backend return basedirs that are ancestors of the current directory. > Backends that return non-ancestor basedirs have higher priority to show the > status of that manually-configured repository. > Do any other backends allow the worktree to be somewhere other than an ancestor of $PWD? Git can, as mentioned above. Subversion can't. (svn(1) always operates on the path given by the positional arguments, if any, else on $PWD.) I'm unsure about others. There doesn't seem to be any way to shadow a GIT_WORK_TREE setting, other than to temporarily set the enable/disable styles so as to exclude git entirely. Is that a problem? Should we implement, say, a hook that gets arguments of the form «${vcs}\0${worktree_root}» and sets $reply to the one to use? We could pass the arguments sorted by disk path and by order of the 'enable' style. I suspect this would be overengineering. > The algorithm used by vcs_info can be configured using 'choose-closest-backend' > zstyle: > > zstyle ':vcs_info:*' choose-closest-backend yes > > By default, old algorithm is used. > > It can also be configured per-backend: > > zstyle ':vcs_info:hg:*' choose-closest-backend no > > This effectively moves the backend into group (1), as if its basedir is never > an ancestor of the current directory. Not sure how useful this is though. > > Signed-off-by: Aleksandr Mezin > --- > v4: back to boolean zstyle, keep old behavior by default, documentation > > Completion/Zsh/Command/_zstyle | 1 + > Doc/Zsh/contrib.yo | 41 +++++++++++++++++++ > Functions/VCS_Info/vcs_info | 30 ++++++++++++-- > > +++ b/Functions/VCS_Info/vcs_info > @@ -124,10 +126,30 @@ vcs_info () { > fi > vcs_comm=() > VCS_INFO_get_cmd > - VCS_INFO_detect_${vcs} && (( found = 1 )) && break > + if VCS_INFO_detect_${vcs}; then > + basedir_realpath="${vcs_comm[basedir]:P}" If vcs_comm[basedir] starts to be used like that, it should be documented as an internal API. (In comments, not yodl) > + zstyle -t ":vcs_info:${vcs}:${usercontext}:${rrn}" choose-closest-backend > + choose_first_available=$? > + > + [[ "${PWD:P}/" == "${basedir_realpath}"/* ]] || choose_first_available=1 If I'm not mistaken, this condition will false negative when [[ $basedir_realpath == / ]] and [[ $PWD != / ]]. > + if (( choose_first_available )) || (( ${#basedir_realpath} > ${#chosen_basedir_realpath} )) ; then > + chosen_vcs="${vcs}" > + chosen_vcs_comm=("${(kv)vcs_comm[@]}") > + chosen_backend_misc=("${(kv)backend_misc[@]}") > + chosen_basedir_realpath="${basedir_realpath}" > + > + (( choose_first_available )) && break > + fi > + fi > done > > - (( found == 0 )) && { > + vcs="${chosen_vcs}" > + vcs_comm=("${(kv)chosen_vcs_comm[@]}") > + backend_misc=("${(kv)chosen_backend_misc[@]}")