Expand argument to :Gwrite

This commit is contained in:
Tim Pope
2018-08-02 21:33:36 -04:00
parent a615172b14
commit b780bce39b

View File

@@ -913,8 +913,8 @@ function! s:buffer_relative(...) dict abort
return s:sub(s:sub(rev,'.\zs/$',''),'^/',a:0 ? a:1 : '') return s:sub(s:sub(rev,'.\zs/$',''),'^/',a:0 ? a:1 : '')
endfunction endfunction
function! s:Relative(prefix) abort function! s:Relative(...) abort
return fugitive#Path(@%, a:prefix) return fugitive#Path(@%, a:0 ? a:1 : './')
endfunction endfunction
function! s:buffer_path(...) dict abort function! s:buffer_path(...) dict abort
@@ -2232,14 +2232,14 @@ function! s:Write(force,...) abort
endif endif
let mytab = tabpagenr() let mytab = tabpagenr()
let mybufnr = bufnr('') let mybufnr = bufnr('')
let path = a:0 ? join(a:000, ' ') : s:Relative('') let path = a:0 ? s:Expand(join(a:000, ' ')) : s:Relative()
if empty(path) if empty(path)
return 'echoerr '.string('fugitive: cannot determine file path') return 'echoerr '.string('fugitive: cannot determine file path')
endif endif
if path =~# '^:\d\>' if path =~# '^:\d\>'
return 'write'.(a:force ? '! ' : ' ').s:fnameescape(s:Generate(s:Expand(path))) return 'write'.(a:force ? '! ' : ' ').s:fnameescape(s:Generate(path))
endif endif
let always_permitted = (s:Relative('') ==# path && s:DirCommitFile(@%)[1] =~# '^0\=$') let always_permitted = ((s:Relative() ==# path || s:Relative('') ==# path) && s:DirCommitFile(@%)[1] =~# '^0\=$')
if !always_permitted && !a:force && (len(s:TreeChomp('diff','--name-status','HEAD','--',path)) || len(s:TreeChomp('ls-files','--others','--',path))) if !always_permitted && !a:force && (len(s:TreeChomp('diff','--name-status','HEAD','--',path)) || len(s:TreeChomp('ls-files','--others','--',path)))
let v:errmsg = 'fugitive: file has uncommitted changes (use ! to override)' let v:errmsg = 'fugitive: file has uncommitted changes (use ! to override)'
return 'echoerr v:errmsg' return 'echoerr v:errmsg'