From bf7b16e99e075b019e56f2fbfb96c493ca3635e2 Mon Sep 17 00:00:00 2001 From: Paul Netherwood <paul.netherwood@beachhorizon.com> Date: Sun, 12 Jan 2020 17:46:58 +0000 Subject: [PATCH] Make top level git path work with Cygwin/MSYS2 Cygwin and MSYS2 used Git for Windows which returns a windows path which doesn't work in vim. This change looks for the presence of the cygpath executable which if present indicates its running under Cygwin or MSYS2. It then uses cypath is to convert the windows path to a compatible path. --- autoload/magit/git.vim | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/autoload/magit/git.vim b/autoload/magit/git.vim index b3fb155..f5f9892 100644 --- a/autoload/magit/git.vim +++ b/autoload/magit/git.vim @@ -52,9 +52,9 @@ function! magit#git#is_work_tree(path) try call magit#utils#chdir(a:path) let top_dir=system(g:magit_git_cmd . " rev-parse --show-toplevel") - if ( executable("cygpath") ) - let top_dir = magit#utils#strip(system("cygpath " . top_dir)) - endif + if ( executable("cygpath") ) + let top_dir = magit#utils#strip(system("cygpath " . top_dir)) + endif if ( v:shell_error != 0 ) return '' endif @@ -75,10 +75,10 @@ function! magit#git#set_top_dir(path) let top_dir=magit#utils#strip( \ system(g:magit_git_cmd . " rev-parse --show-toplevel")) . "/" let git_dir=magit#utils#strip(system(g:magit_git_cmd . " rev-parse --git-dir")) . "/" - if ( executable("cygpath") ) - let top_dir = magit#utils#strip(system("cygpath " . top_dir)) - let git_dir = magit#utils#strip(system("cygpath " . git_dir)) - endif + if ( executable("cygpath") ) + let top_dir = magit#utils#strip(system("cygpath " . top_dir)) + let git_dir = magit#utils#strip(system("cygpath " . git_dir)) + endif catch 'shell_error' call magit#sys#print_shell_error() throw 'set_top_dir_error' -- GitLab