zsh-workers
 help / color / mirror / code / Atom feed
* [PATCH] Ask git for its toplevel directory directly
@ 2013-11-14 17:22 Clemens Hammacher
  0 siblings, 0 replies; only message in thread
From: Clemens Hammacher @ 2013-11-14 17:22 UTC (permalink / raw)
  To: Zsh Workers List; +Cc: Clemens Hammacher

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


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2013-11-14 18:01 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-11-14 17:22 [PATCH] Ask git for its toplevel directory directly Clemens Hammacher

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).