Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

[PATCH] Ask git for its toplevel directory directly



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



Messages sorted by: Reverse Date, Date, Thread, Author