diff --git a/autoload/magit/utils.vim b/autoload/magit/utils.vim index 84d26bcb74b61e5bd28c0bfde4e277c58e2844a4..290692381e7bf0fb57a34f3e1aee98663f26f385 100644 --- a/autoload/magit/utils.vim +++ b/autoload/magit/utils.vim @@ -25,7 +25,7 @@ endfunction let s:magit_cd_cmd = exists('*haslocaldir') && haslocaldir() ? 'lcd ' : 'cd ' " magit#utils#lcd: helper function to lcd. use cd if lcd doesn't exists function! magit#utils#lcd(dir) - execute s:magit_cd_cmd . a:dir + execute s:magit_cd_cmd . fnameescape(a:dir) endfunction " magit#utils#clear_undo: this function clear local undo history. @@ -55,7 +55,7 @@ endfunction function! magit#utils#system(...) let dir = getcwd() try - execute s:magit_cd_cmd . magit#git#top_dir() + call magit#utils#lcd(magit#git#top_dir()) " List as system() input is since v7.4.247, it is safe to check " systemlist, which is sine v7.4.248 if exists('*systemlist') @@ -75,7 +75,7 @@ function! magit#utils#system(...) endif endif finally - execute s:magit_cd_cmd . dir + call magit#utils#lcd(dir) endtry endfunction @@ -88,7 +88,7 @@ endfunction function! magit#utils#systemlist(...) let dir = getcwd() try - execute s:magit_cd_cmd . magit#git#top_dir() + call magit#utils#lcd(magit#git#top_dir()) " systemlist since v7.4.248 if exists('*systemlist') return call('systemlist', a:000) @@ -96,7 +96,7 @@ function! magit#utils#systemlist(...) return split(call('magit#utils#system', a:000), '\n') endif finally - execute s:magit_cd_cmd . dir + call magit#utils#lcd(dir) endtry endfunction diff --git a/plugin/magit.vim b/plugin/magit.vim index 7ea609c92df91c47346bee6fa53e44d2d5475c29..9facf1fb1ef23a3e55ba9eabcee5b620fe2f90a2 100644 --- a/plugin/magit.vim +++ b/plugin/magit.vim @@ -778,7 +778,7 @@ function! magit#show_magit(display, ...) throw 'magit_not_in_git_repo' endif - let buffer_name='magit://' . git_dir + let buffer_name=fnameescape('magit://' . git_dir) let magit_win = magit#utils#search_buffer_in_windows(buffer_name)