mirror of
https://github.com/tpope/vim-fugitive.git
synced 2025-11-11 12:53:52 -05:00
Eliminate use of ":write !"
This is a prerequisite of eliminating the use of the shell in favor of direct execution via jobs.
This commit is contained in:
@@ -2369,7 +2369,7 @@ function! fugitive#FileReadCmd(...) abort
|
|||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! fugitive#FileWriteCmd(...) abort
|
function! fugitive#FileWriteCmd(...) abort
|
||||||
let tmp = tempname()
|
let temp = tempname()
|
||||||
let amatch = a:0 ? a:1 : expand('<amatch>')
|
let amatch = a:0 ? a:1 : expand('<amatch>')
|
||||||
let autype = a:0 > 1 ? 'Buf' : 'File'
|
let autype = a:0 > 1 ? 'Buf' : 'File'
|
||||||
if exists('#' . autype . 'WritePre')
|
if exists('#' . autype . 'WritePre')
|
||||||
@@ -2380,17 +2380,13 @@ function! fugitive#FileWriteCmd(...) abort
|
|||||||
if commit !~# '^[0-3]$' || !v:cmdbang && (line("'[") != 1 || line("']") != line('$'))
|
if commit !~# '^[0-3]$' || !v:cmdbang && (line("'[") != 1 || line("']") != line('$'))
|
||||||
return "noautocmd '[,']write" . (v:cmdbang ? '!' : '') . ' ' . s:fnameescape(amatch)
|
return "noautocmd '[,']write" . (v:cmdbang ? '!' : '') . ' ' . s:fnameescape(amatch)
|
||||||
endif
|
endif
|
||||||
if exists('+guioptions') && &guioptions =~# '!'
|
silent execute "noautocmd keepalt '[,']write ".temp
|
||||||
let guioptions = &guioptions
|
let hash = s:TreeChomp([dir, 'hash-object', '-w', '--', temp])
|
||||||
set guioptions-=!
|
|
||||||
endif
|
|
||||||
silent execute "'[,']write !".fugitive#Prepare(dir, 'hash-object', '-w', '--stdin', '--').' > '.tmp
|
|
||||||
let sha1 = readfile(tmp)[0]
|
|
||||||
let old_mode = matchstr(s:ChompError(['ls-files', '--stage', '.' . file], dir)[0], '^\d\+')
|
let old_mode = matchstr(s:ChompError(['ls-files', '--stage', '.' . file], dir)[0], '^\d\+')
|
||||||
if empty(old_mode)
|
if empty(old_mode)
|
||||||
let old_mode = executable(s:Tree(dir) . file) ? '100755' : '100644'
|
let old_mode = executable(s:Tree(dir) . file) ? '100755' : '100644'
|
||||||
endif
|
endif
|
||||||
let error = s:UpdateIndex(dir, [old_mode, sha1, commit, file[1:-1]])
|
let error = s:UpdateIndex(dir, [old_mode, hash, commit, file[1:-1]])
|
||||||
if empty(error)
|
if empty(error)
|
||||||
setlocal nomodified
|
setlocal nomodified
|
||||||
if exists('#' . autype . 'WritePost')
|
if exists('#' . autype . 'WritePost')
|
||||||
@@ -2400,11 +2396,10 @@ function! fugitive#FileWriteCmd(...) abort
|
|||||||
else
|
else
|
||||||
return 'echoerr '.string('fugitive: '.error)
|
return 'echoerr '.string('fugitive: '.error)
|
||||||
endif
|
endif
|
||||||
|
catch /^fugitive:/
|
||||||
|
return 'echoerr ' . string(v:exception)
|
||||||
finally
|
finally
|
||||||
if exists('guioptions')
|
call delete(temp)
|
||||||
let &guioptions = guioptions
|
|
||||||
endif
|
|
||||||
call delete(tmp)
|
|
||||||
endtry
|
endtry
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user