mirror of
https://github.com/tpope/vim-fugitive.git
synced 2025-11-09 12:03:47 -05:00
Clearer error message on attempt to delete directory
Recursive deletion is too dangerous to provide without a confirmation prompt. Closes https://github.com/tpope/vim-fugitive/issues/1364
This commit is contained in:
@@ -3064,6 +3064,9 @@ function! s:StageDelete(lnum1, lnum2, count) abort
|
|||||||
endif
|
endif
|
||||||
if info.status ==# 'D'
|
if info.status ==# 'D'
|
||||||
let undo = 'Gremove'
|
let undo = 'Gremove'
|
||||||
|
elseif info.paths[0] =~# '/$'
|
||||||
|
let err .= '|echoerr ' . string('fugitive: will not delete directory ' . string(info.relative[0]))
|
||||||
|
break
|
||||||
else
|
else
|
||||||
let undo = 'Gread ' . s:TreeChomp('hash-object', '-w', '--', info.paths[0])[0:10]
|
let undo = 'Gread ' . s:TreeChomp('hash-object', '-w', '--', info.paths[0])[0:10]
|
||||||
endif
|
endif
|
||||||
@@ -3090,14 +3093,18 @@ function! s:StageDelete(lnum1, lnum2, count) abort
|
|||||||
call add(restore, ':Gsplit ' . s:fnameescape(info.relative[0]) . '|' . undo)
|
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)
|
||||||
endtry
|
endtry
|
||||||
if empty(restore)
|
if empty(restore)
|
||||||
return err[1:-1]
|
return err[1:-1]
|
||||||
endif
|
endif
|
||||||
exe s:ReloadStatus()
|
exe s:ReloadStatus()
|
||||||
call s:StageReveal()
|
call s:StageReveal()
|
||||||
|
if len(restore)
|
||||||
return 'checktime|redraw|echomsg ' . string('To restore, ' . join(restore, '|')) . err
|
return 'checktime|redraw|echomsg ' . string('To restore, ' . join(restore, '|')) . err
|
||||||
|
else
|
||||||
|
return 'checktime|redraw' . err
|
||||||
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:StageIgnore(lnum1, lnum2, count) abort
|
function! s:StageIgnore(lnum1, lnum2, count) abort
|
||||||
|
|||||||
Reference in New Issue
Block a user