Fix X on removed file

References https://github.com/tpope/vim-fugitive/issues/1343
This commit is contained in:
Tim Pope
2019-09-22 21:17:49 -04:00
parent 1d8c0a38b2
commit 37088aaf65

View File

@@ -3005,9 +3005,10 @@ function! s:StageDelete(lnum1, lnum2, count) abort
if empty(info.paths) if empty(info.paths)
continue continue
endif endif
let hash = s:TreeChomp('hash-object', '-w', '--', info.paths[0]) if info.status ==# 'D'
if empty(hash) let undo = 'Gremove'
continue else
let undo = 'Gread ' . s:TreeChomp('hash-object', '-w', '--', info.paths[0])[0:10]
endif endif
if info.patch if info.patch
call s:StageApply(info, 1, info.section ==# 'Staged' ? ['--index'] : []) call s:StageApply(info, 1, info.section ==# 'Staged' ? ['--index'] : [])
@@ -3029,7 +3030,7 @@ function! s:StageDelete(lnum1, lnum2, count) abort
else else
call s:TreeChomp('checkout', 'HEAD^{}', '--', info.paths[0]) call s:TreeChomp('checkout', 'HEAD^{}', '--', info.paths[0])
endif endif
call add(restore, ':Gsplit ' . s:fnameescape(info.relative[0]) . '|Gread ' . hash[0:6]) call add(restore, ':Gsplit ' . s:fnameescape(info.relative[0]) . '|' . undo)
endfor endfor
catch /^fugitive:/ catch /^fugitive:/
let err = '|echoerr ' . string(v:exception) let err = '|echoerr ' . string(v:exception)