Use -- to disambiguate arguments

This is to enable future replacement of s:Prepare() with
fugitive#Prepare().
This commit is contained in:
Tim Pope 2018-08-19 20:52:29 -04:00
parent 2b5effe2f1
commit b1ab990314

View File

@ -269,7 +269,7 @@ function! fugitive#Head(...) abort
endfunction
function! fugitive#RevParse(rev, ...) abort
let hash = system(s:Prepare(a:0 ? a:1 : b:git_dir, 'rev-parse', '--verify', a:rev))[0:-2]
let hash = system(s:Prepare(a:0 ? a:1 : b:git_dir, 'rev-parse', '--verify', a:rev, '--'))[0:-2]
if !v:shell_error && hash =~# '^\x\{40\}$'
return hash
endif
@ -300,7 +300,7 @@ function! fugitive#RemoteUrl(...) abort
if fugitive#GitVersion() =~# '^[01]\.\|^2\.[0-6]\.'
return fugitive#Config('remote.' . remote . '.url')
endif
let cmd = s:Prepare(dir, 'remote', 'get-url', remote)
let cmd = s:Prepare(dir, 'remote', 'get-url', remote, '--')
let out = substitute(system(cmd), "\n$", '', '')
return v:shell_error ? '' : out
endfunction
@ -589,7 +589,7 @@ function! fugitive#Route(object, ...) abort
endif
endif
if commit !~# '^[0-9a-f]\{40\}$'
let commit = system(s:Prepare(dir, 'rev-parse', '--verify', commit))[0:-2]
let commit = system(s:Prepare(dir, 'rev-parse', '--verify', commit, '--'))[0:-2]
let commit = v:shell_error ? '' : commit
endif
if len(commit)
@ -775,7 +775,7 @@ function! fugitive#getfsize(url) abort
let entry = s:PathInfo(a:url)
if entry[4] == -2 && entry[2] ==# 'blob' && len(entry[3])
let dir = s:DirCommitFile(a:url)[0]
let size = +system(s:Prepare(dir, 'cat-file', '-s', entry[3]))
let size = +system(s:Prepare(dir, 'cat-file', '-s', entry[3], '--'))
let entry[4] = v:shell_error ? -1 : size
endif
return entry[4]
@ -867,7 +867,7 @@ function! s:BlobTemp(url) abort
endif
if commit =~# '^\d$' || !filereadable(tempfile)
let rev = s:DirRev(a:url)[1]
let command = s:Prepare(dir, 'cat-file', 'blob', rev)
let command = s:Prepare(dir, 'cat-file', 'blob', rev, '--')
call s:TempCmd(tempfile, command)
if v:shell_error
call delete(tempfile)
@ -1289,9 +1289,9 @@ function! fugitive#FileReadCmd(...) abort
return 'noautocmd ' . line . 'read ' . s:fnameescape(amatch)
endif
if rev !~# ':'
let cmd = s:Prepare(dir, 'log', '--pretty=format:%B', '-1', rev)
let cmd = s:Prepare(dir, 'log', '--pretty=format:%B', '-1', rev, '--')
else
let cmd = s:Prepare(dir, 'cat-file', '-p', rev)
let cmd = s:Prepare(dir, 'cat-file', '-p', rev, '--')
endif
return line . 'read !' . escape(cmd, '!#%')
endfunction
@ -1308,10 +1308,10 @@ function! fugitive#FileWriteCmd(...) abort
if commit !~# '^[0-3]$' || !v:cmdbang && (line("'[") != 1 || line("']") != line('$'))
return "noautocmd '[,']write" . (v:cmdbang ? '!' : '') . ' ' . s:fnameescape(amatch)
endif
silent execute "'[,']write !".s:Prepare(dir, 'hash-object', '-w', '--stdin').' > '.tmp
silent execute "'[,']write !".s:Prepare(dir, 'hash-object', '-w', '--stdin', '--').' > '.tmp
let sha1 = readfile(tmp)[0]
let old_mode = matchstr(system(s:Prepare(dir, 'ls-files', '--stage', file[1:-1])), '^\d\+')
if old_mode == ''
let old_mode = matchstr(system(s:Prepare(dir, 'ls-files', '--stage', '--', '.' . file)), '^\d\+')
if empty(old_mode)
let old_mode = executable(s:Tree(dir) . file) ? '100755' : '100644'
endif
let info = old_mode.' '.sha1.' '.commit."\t".file[1:-1]