From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 20975 invoked by alias); 14 Nov 2013 18:01:12 -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: 31985 Received: (qmail 11894 invoked from network); 14 Nov 2013 18:01:04 -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.6 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.2 From: Clemens Hammacher To: Zsh Workers List Cc: Clemens Hammacher Subject: [PATCH] Ask git for its toplevel directory directly Date: Thu, 14 Nov 2013 18:22:23 +0100 Message-Id: <1384449743-40199-1-git-send-email-hammacher@cs.uni-saarland.de> X-Mailer: git-send-email 1.8.4.2 X-DCC-SION-Metrics: mail.cs.uni-saarland.de; whitelist X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-3.0 (theia.rz.uni-saarland.de [134.96.7.31]); Thu, 14 Nov 2013 18:24:10 +0100 (CET) X-AntiVirus: checked by AntiVir MailGate (version: 2.1.2-14; AVE: 7.9.10.68; VDF: 7.11.99.164; host: AntiVir1) This avoids printing the wrong base directory if $PWD contains a symlink. If /tmp is the base and $PWD is /tmp/b, where b is a symlink (to "." or any other directory), git rev-parse --show-prefix will show the link target instead of b. Thus the replacement in $PWD does not work. Fortunately, there also exists git rev-parse --show-toplevel, which reliably returns the base directory. --- Functions/VCS_Info/Backends/VCS_INFO_get_data_git | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Functions/VCS_Info/Backends/VCS_INFO_get_data_git b/Functions/VCS_Info/Backends/VCS_INFO_get_data_git index c44be39..e6791cb 100644 --- a/Functions/VCS_Info/Backends/VCS_INFO_get_data_git +++ b/Functions/VCS_Info/Backends/VCS_INFO_get_data_git @@ -132,7 +132,7 @@ fi VCS_INFO_adjust VCS_INFO_git_getaction ${gitdir} -gitbase=${PWD%/${$( ${vcs_comm[cmd]} rev-parse --show-prefix )%/##}} +gitbase=$( ${vcs_comm[cmd]} rev-parse --show-toplevel ) rrn=${gitbase:t} local patchdir=${gitdir}/patches/${gitbranch} -- 1.8.4.2