Support FileWriteCmd
This correctly requires a bang to write a partial file, but the error message is E212 rather than the more appropriate E140.
This commit is contained in:
parent
99f0431135
commit
56e4947843
@ -2822,15 +2822,15 @@ function! fugitive#FileReadCmd(...) abort
|
||||
return line . 'read !' . escape(cmd, '!#%')
|
||||
endfunction
|
||||
|
||||
function! fugitive#BufWriteCmd(...) abort
|
||||
function! fugitive#FileWriteCmd(...) abort
|
||||
let tmp = tempname()
|
||||
let amatch = a:0 ? a:1 : expand('<amatch>')
|
||||
try
|
||||
let [dir, commit, file] = s:DirCommitFile(amatch)
|
||||
if commit !~# '^[0-3]$'
|
||||
return 'noautocmd write' . (v:cmdbang ? '!' : '') . ' ' . s:fnameescape(amatch)
|
||||
if commit !~# '^[0-3]$' || !v:cmdbang && (line("'[") != 1 || line("']") != line('$'))
|
||||
return "noautocmd '[,']write" . (v:cmdbang ? '!' : '') . ' ' . s:fnameescape(amatch)
|
||||
endif
|
||||
silent execute 'write !'.fugitive#Prepare(dir, 'hash-object', '-w', '--stdin').' > '.tmp
|
||||
silent execute "'[,']write !".fugitive#Prepare(dir, 'hash-object', '-w', '--stdin').' > '.tmp
|
||||
let sha1 = readfile(tmp)[0]
|
||||
let old_mode = matchstr(system(fugitive#Prepare(dir, 'ls-files', '--stage', file[1:-1])), '^\d\+')
|
||||
if old_mode == ''
|
||||
@ -2945,6 +2945,10 @@ function! fugitive#BufReadCmd(...) abort
|
||||
endtry
|
||||
endfunction
|
||||
|
||||
function! fugitive#BufWriteCmd(...) abort
|
||||
return call('fugitive#FileWriteCmd', a:000)
|
||||
endfunction
|
||||
|
||||
function! fugitive#SourceCmd(...) abort
|
||||
let amatch = a:0 ? a:1 : expand('<amatch>')
|
||||
let temp = s:BlobTemp(amatch)
|
||||
|
@ -183,6 +183,7 @@ augroup fugitive
|
||||
autocmd BufReadCmd fugitive://*//* exe fugitive#BufReadCmd()
|
||||
autocmd BufWriteCmd fugitive://*//[0-3]/* exe fugitive#BufWriteCmd()
|
||||
autocmd FileReadCmd fugitive://*//* exe fugitive#FileReadCmd()
|
||||
autocmd FileWriteCmd fugitive://*//[0-3]/* exe fugitive#FileWriteCmd()
|
||||
autocmd SourceCmd fugitive://*//* nested exe fugitive#SourceCmd()
|
||||
|
||||
autocmd User Flags call Hoist('buffer', function('FugitiveStatusline'))
|
||||
|
Loading…
Reference in New Issue
Block a user