Cater for powershell as well as cmd for windows users

This commit is contained in:
Craig Main 2014-03-31 08:02:22 +02:00 committed by Tim Pope
parent c1664de7b4
commit 51cdb1b190

View File

@ -29,7 +29,7 @@ endfunction
function! s:shellesc(arg) abort
if a:arg =~ '^[A-Za-z0-9_/.-]\+$'
return a:arg
elseif &shell =~# 'cmd'
elseif &shell =~# 'cmd' || &shell =~# 'power'
return '"'.s:gsub(s:gsub(a:arg, '"', '""'), '\%', '"%"').'"'
else
return shellescape(a:arg)
@ -951,7 +951,7 @@ function! s:Commit(args) abort
try
try
execute cd.s:fnameescape(s:repo().tree())
if &shell =~# 'cmd'
if &shell =~# 'cmd' || &shell =~# 'power'
let command = ''
let old_editor = $GIT_EDITOR
let $GIT_EDITOR = 'false'
@ -2037,14 +2037,14 @@ function! s:ReplaceCmd(cmd,...) abort
let prefix = ''
try
if a:0 && a:1 != ''
if &shell =~# 'cmd'
if &shell =~# 'cmd' || &shell =~# 'power'
let old_index = $GIT_INDEX_FILE
let $GIT_INDEX_FILE = a:1
else
let prefix = 'env GIT_INDEX_FILE='.s:shellesc(a:1).' '
endif
endif
if &shell =~# 'cmd'
if &shell =~# 'cmd' || &shell =~# 'power'
let cmd_escape_char = &shellxquote == '(' ? '^' : '^^^'
call system('cmd /c "'.prefix.s:gsub(a:cmd,'[<>]', cmd_escape_char.'&').' > '.tmp.'"')
else
@ -2191,7 +2191,7 @@ function! s:BufWriteIndexFile() abort
endif
let info = old_mode.' '.sha1.' '.stage."\t".path
call writefile([info],tmp)
if &shell =~# 'cmd'
if &shell =~# 'cmd' || &shell =~# 'power'
let error = system('type '.s:gsub(tmp,'/','\\').'|'.s:repo().git_command('update-index','--index-info'))
else
let error = system(s:repo().git_command('update-index','--index-info').' < '.tmp)