Skip to content

Commit

Permalink
Make top level git path work with Cygwin/MSYS2
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Paul Netherwood authored and jreybert committed Jan 12, 2020
1 parent 3a0c9f3 commit bf7b16e
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions autoload/magit/git.vim
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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'
Expand Down

0 comments on commit bf7b16e

Please sign in to comment.