From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 20964 invoked by alias); 11 Nov 2014 10:33:31 -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: X-Seq: 33672 Received: (qmail 12632 invoked from network); 11 Nov 2014 10:33:19 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:from:to:cc:subject:message-id:references:mime-version :content-type:content-disposition:content-transfer-encoding :in-reply-to:user-agent; bh=ybCXpIYlocXqPp6QOfkw7NzlLbAar0CzxRRy4+LRVZM=; b=D5DRCPMYmJV7JTasyMVvN1SCUuphCYd0sZwPIJiZsQNHZRCrbMOmfsCJL4egQ6QEwB kkh42lNiLmTOCy1k5UMxdNnLt1+Rr0HU9XmG6IGPgShCO2mYLLgYE+8iRVz5juD1hmYL TgcScqA9KF5kiNl653G8iruQUWu0eyAJsc/tThksIpfrIjeB15DwK1Nc2bgHV1LHEFs6 +X0kXmuF5Cz98+p6RD0X1FWvCZl3btVs/Knh4XNPUTem6Uqy2N47CQyuBrXPuU4TISOv ZX9kTzzIRLm8JMXpzwaljxpHBCsGxPsOjIgJpIMi7LFsDdgLeIu9Y8CHc8r5/bd0cWNR L0jQ== X-Received: by 10.180.104.232 with SMTP id gh8mr6331830wib.78.1415700474558; Tue, 11 Nov 2014 02:07:54 -0800 (PST) Date: Tue, 11 Nov 2014 11:07:52 +0100 From: Marc Finet To: Frank Terbeck Cc: zsh-workers@zsh.org Subject: Re: [PATCH 6/9] vcs_info quilt: fix unapplied detection on sub-directory Message-ID: <20141111100752.GA8974@mlap.lactee> References: <1410557443-24178-1-git-send-email-m.dreadlock@gmail.com> <1410557443-24178-7-git-send-email-m.dreadlock@gmail.com> <87lhpm7ctw.fsf@ft.bewatermyfriend.org> <20141009003619.00001016@mlap.lactee> <8761ft44db.fsf@ft.bewatermyfriend.org> <20141016065926.3a4d503b@mlap.lactee> <87lhogctsb.fsf@ft.bewatermyfriend.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <87lhogctsb.fsf@ft.bewatermyfriend.org> User-Agent: Mutt/1.5.23 (2014-03-12) Sorry for lack of reactivity ;|. On Thu, Oct 16, 2014 at 10:17:56AM +0200, Frank Terbeck wrote: > Marc Finet wrote: > > This is where the problem occurs, applied uses relative path, while > > unapplied lists absolute path, because QUILT_PATCHES is set to an > > absolute path. e.g. > > ~/src/from-debian/gmrun-0.9.2# QUILT_PATCHES=$(pwd)/debian/patches quilt applied > > /home/marc/src/from-debian/gmrun-0.9.2/debian/patches/10-escaping.patch > > ... > > /home/marc/src/from-debian/gmrun-0.9.2/debian/patches/80-selectoption.pat > > ~/src/from-debian/gmrun-0.9.2# quilt applied > > debian/patches/10-escaping.patch > > debian/patches/20-includes.patch > > debian/patches/30-fix-gcc-4.3-build.patch > > debian/patches/40-history_string.patch > > debian/patches/50-empty-history.patch > > debian/patches/60-fix_gtkcompletionline.patch > > > > So applied and unapplied lists are considered differents. The > > .pc/applied-patches file contains only relative paths. > > I see. That could be fixed, I guess. Either by making the unapplied list > absolute, or by trimming off the "repository's" root-directory from the > absolute paths before comparing. I do not see the point of specifying an absolute path for QUILT_PATCHES (or quilt-patch-dir) since relative path work with quilt (it automatically looks for upper directories if needed). Worse, specifying absolute path in QUILT_PATCHES makes quilt unable to create the .pc in the root since there is no root to deduce; on relative path, root is the path where the QUILT_PATCHES path is found. Anyway, the following patch fixes all the cases, i.e. specifying path (both absolute or "relative") in QUILT_PATCHES or quilt-patch-dir. > >> > So I do not understand the role of quilt-patch-dir as for me it takes > >> > the role of QUILT_PATCHES except the missing '/patches'. Moreover changing > >> > to sub-directory in cases 1, 3 and 5 makes applied patch detection failing > >> > because: > >> > >> The ‘quilt-patch-dir’ style *sets* QUILT_PATCHES if set. The system > >> also sets QUILT_PATCHES to an absolute path-name, which should make it > >> work in subdirectories as well. > > I do not see where the QUILT_PATCHES variable is set (I mean exported to > > the shell for further quilt commands using this 'detected' value). Maybe > > your hook sets it according to the documentation: "Note: you can use > > vcs_info to keep the value of $QUILT_PATCHES correct all the time via the > > post-quilt hook" > > Quilt is only called directly once in vcs_info's quilt code, if I'm not > mistaken. And that's here: > > [...] > zstyle -s "${context}" quiltcommand quiltcommand || quiltcommand='quilt' > unapplied=( ${(f)"$(QUILT_PATCHES=$patches $quiltcommand --quiltrc /dev/null unapplied 2> /dev/null)"} ) > [...] > > I don't have any hooks for quilt behaviour set anymore. But given, that > the hook is called like this: > > VCS_INFO_hook 'post-quilt' ${mode} ${patches} ${pc:-\\-nopc-} > > You could likely set such a hook like this: > > function +vi-quilt-patches() { > if [[ -n $2 ]]; then > typeset -gx "QUILT_PATCHES=$2" > fi > } > > zstyle ':vcs_info:*+post-quilt:*:*' hooks quilt-patches > > To have $QUILT_PATCHES match vcs_info's idea of the patch directory. Ok, we agree on that then, I thought that some other part was doing this automagically. Thanks, Marc diff --git a/Functions/VCS_Info/VCS_INFO_quilt b/Functions/VCS_Info/VCS_INFO_quilt index 258a08a..49abc87 100644 --- a/Functions/VCS_Info/VCS_INFO_quilt +++ b/Functions/VCS_Info/VCS_INFO_quilt @@ -84,7 +84,7 @@ function VCS_INFO_quilt() { emulate -L zsh setopt extendedglob local mode="$1" - local patches pc tmp qstring root + local patches pc qstring root abs_patches local -i ret local -x context local -a applied unapplied all applied_string unapplied_string quiltcommand @@ -107,13 +107,21 @@ function VCS_INFO_quilt() { zstyle -s "${context}" quilt-patch-dir patches || patches="${QUILT_PATCHES}" if [[ "${patches}" != /* ]]; then - tmp=${patches:-patches} - patches="$(VCS_INFO_quilt-dirfind "${tmp}")" + patches=${patches:-patches} + abs_patches="$(VCS_INFO_quilt-dirfind "${patches}")" ret=$? (( ret )) && return ${ret} - patches=${patches}/${tmp} else [[ -d ${patches} ]] || return 1 + abs_patches=${patches} + # find root + patches="$(VCS_INFO_realpath ${abs_patches})" + root="$(VCS_INFO_realpath .)" + while [[ "${patches}" != ${root}/* ]]; do + root="$(VCS_INFO_realpath ${root}/..)" + [[ "${root}" = "/" ]] && return 1 + done + patches="${patches#$root/}" fi pc="$(VCS_INFO_quilt-dirfind .pc .version)" @@ -185,6 +193,6 @@ function VCS_INFO_quilt() { ;; esac - VCS_INFO_hook 'post-quilt' ${mode} ${patches} ${pc:-\\-nopc-} + VCS_INFO_hook 'post-quilt' ${mode} ${abs_patches} ${pc:-\\-nopc-} } VCS_INFO_quilt "$@"