zsh-workers
 help / color / mirror / code / Atom feed
From: Clemens Hammacher <hammacher@cs.uni-saarland.de>
To: Zsh Workers List <zsh-workers@zsh.org>
Cc: Clemens Hammacher <hammacher@cs.uni-saarland.de>
Subject: [PATCH] Ask git for its toplevel directory directly
Date: Thu, 14 Nov 2013 18:22:23 +0100	[thread overview]
Message-ID: <1384449743-40199-1-git-send-email-hammacher@cs.uni-saarland.de> (raw)

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


                 reply	other threads:[~2013-11-14 18:01 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1384449743-40199-1-git-send-email-hammacher@cs.uni-saarland.de \
    --to=hammacher@cs.uni-saarland.de \
    --cc=zsh-workers@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).