From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from primenet.com.au (ns1.primenet.com.au [203.24.36.2]) by inbox.vuxu.org (OpenSMTPD) with ESMTP id 600b847e for ; Sat, 21 Dec 2019 21:05:44 +0000 (UTC) Received: (qmail 24114 invoked by alias); 21 Dec 2019 15:59:14 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: List-Unsubscribe: X-Seq: 45115 Received: (qmail 3111 invoked by uid 1010); 21 Dec 2019 15:59:14 -0000 X-Qmail-Scanner-Diagnostics: from out1-smtp.messagingengine.com by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.102.1/25663. spamassassin: 3.4.2. Clear:RC:0(66.111.4.25):SA:0(-1.9/5.0):. Processed in 2.868789 secs); 21 Dec 2019 15:59:14 -0000 X-Envelope-From: danielsh@apache.org X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | Received-SPF: softfail (ns1.primenet.com.au: transitioning SPF record at amazonses.com does not designate 66.111.4.25 as permitted sender) X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedufedrvdduhedgkedvucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefhvffufffkofgjfhestddtredtre dttdenucfhrhhomhepffgrnhhivghlucfuhhgrhhgrfhcuoegurghnihgvlhhshhesrghp rggthhgvrdhorhhgqeenucfkphepjeelrddukedtrdehjedrudduleenucfrrghrrghmpe hmrghilhhfrhhomhepuggrnhhivghlshhhsegrphgrtghhvgdrohhrghenucevlhhushht vghrufhiiigvpedt X-ME-Proxy: From: Daniel Shahaf To: zsh-workers@zsh.org Subject: [PATCH 2/5] vcs_info examples: Make the quilt-patch-dir example friendlier. Date: Sat, 21 Dec 2019 15:58:25 +0000 Message-Id: <20191221155828.25950-2-danielsh@apache.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20191221155828.25950-1-danielsh@apache.org> References: <20191221155828.25950-1-danielsh@apache.org> - Document that no code at all is necessary for Pareto correctness - Remove a recommendation to rely on implementation details (${rrn}); instead, rely only on ${context}, which is a documented API. --- Misc/vcs_info-examples | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/Misc/vcs_info-examples b/Misc/vcs_info-examples index 028fe62b0..456b3a85b 100644 --- a/Misc/vcs_info-examples +++ b/Misc/vcs_info-examples @@ -468,8 +468,16 @@ zstyle ':vcs_info:-quilt-.quilt-standalone:*:*' quilt-patch-dir debian/patches # and so we want addon mode to also use a $QUILT_PATCHES value of # `debian/patches' in some directories. In the other directories we never # want the default `patches' though but a dedicated place for them. -# Say `~/patches/'. Now we'll use some evaluated-style -# magic to achieve all that: +# Say `~/patches/'. +# +# First of all, even without any configuration, vcs_info will do the right +# thing most of the time. Whenever quilt has already run in a directory, +# vcs_info will figure out whether that directory uses `patches' or +# `debian/patches' by interrogating metadata in the `.pc/' subdirectory, +# which quilt creates. To make vcs_info find the patches dir correctly even +# when the `.pc/' directory doesn't exist, read on. +# +# We'll use some evaluated-style magic to achieve that: zstyle -e ':vcs_info:*.quilt-addon:*:*' quilt-patch-dir 'my-patches-func' # That runs something called `my-patches-func', and the value of $reply is @@ -486,19 +494,17 @@ function my-patches-func() { fi # Now the part about the dedicated directory is a little trickier. - # It requires some knowledge of vcs_info's internals. Not much though. - # Everything about this is described in the manual because this - # variable (plus a few others) may be of interest in hooks, where - # they are available, too. - # - # The variable in question here is `$rrn' which is an abbreviation - # of repository-root-name. if you're in + # The variable in question here is `$context', which is the zstyle + # context used for lookups. Its last component is the repository-root-name, + # or ${rrn} for short. If you're in # /usr/src/zsh/Functions # and the repository being # /usr/src/zsh - # then the value of `$rrn' is `zsh'. Now in case the variable is - # empty (it shouldn't at this point, but you never know), let's - # drop back to quilt's default "patches". + # then the value of `$rrn' would be `zsh'. + local rrn=${context##*:} + + # Now, in case the variable is empty (it shouldn't at this point, but you + # never know), let's drop back to quilt's default value, "patches". if [[ -z ${rrn} ]]; then reply=( patches ) return 0