Improve error handling on :Gstatus X
This commit is contained in:
parent
15df3f8959
commit
54bc4ab9dd
@ -1830,8 +1830,8 @@ function! fugitive#BufReadStatus() abort
|
|||||||
nnoremap <buffer> <silent> R :echohl WarningMsg<Bar>echo 'Reloading is automatic. Use :e to force'<Bar>echohl NONE<CR>
|
nnoremap <buffer> <silent> R :echohl WarningMsg<Bar>echo 'Reloading is automatic. Use :e to force'<Bar>echohl NONE<CR>
|
||||||
nnoremap <buffer> <silent> g<Bar> :<C-U>echoerr 'Changed to X'<CR>
|
nnoremap <buffer> <silent> g<Bar> :<C-U>echoerr 'Changed to X'<CR>
|
||||||
xnoremap <buffer> <silent> g<Bar> :<C-U>echoerr 'Changed to X'<CR>
|
xnoremap <buffer> <silent> g<Bar> :<C-U>echoerr 'Changed to X'<CR>
|
||||||
nnoremap <buffer> <silent> X :<C-U>execute <SID>StageDelete(line('.'),v:count)<CR>
|
nnoremap <buffer> <silent> X :<C-U>execute <SID>StageDelete(line('.'), line('.'), v:count)<CR>
|
||||||
xnoremap <buffer> <silent> X :<C-U>execute <SID>StageDelete(line("'<"),line("'>")-line("'<")+1)<CR>
|
xnoremap <buffer> <silent> X :<C-U>execute <SID>StageDelete(line("'<"), line("'<"), v:count)<CR>
|
||||||
nnoremap <buffer> . :<C-U> <C-R>=<SID>StageArgs(0)<CR><Home>
|
nnoremap <buffer> . :<C-U> <C-R>=<SID>StageArgs(0)<CR><Home>
|
||||||
xnoremap <buffer> . :<C-U> <C-R>=<SID>StageArgs(1)<CR><Home>
|
xnoremap <buffer> . :<C-U> <C-R>=<SID>StageArgs(1)<CR><Home>
|
||||||
nnoremap <buffer> <silent> <F1> :help fugitive-mappings<CR>
|
nnoremap <buffer> <silent> <F1> :help fugitive-mappings<CR>
|
||||||
@ -2835,20 +2835,19 @@ function! s:StageApply(info, reverse, extra) abort
|
|||||||
call s:throw(output)
|
call s:throw(output)
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:StageDelete(lnum, count) abort
|
function! s:StageDelete(lnum, ignored, count) abort
|
||||||
let info = get(s:Selection(a:lnum, -a:count), 0, {'filename': ''})
|
let info = get(s:Selection(a:lnum, a:lnum), 0, {'filename': ''})
|
||||||
if empty(info.filename)
|
if empty(info.filename)
|
||||||
return ''
|
return ''
|
||||||
endif
|
endif
|
||||||
let hash = s:TreeChomp('hash-object', '-w', '--', info.paths[0])
|
let hash = s:TreeChomp('hash-object', '-w', '--', info.paths[0])
|
||||||
|
try
|
||||||
if empty(hash)
|
if empty(hash)
|
||||||
return ''
|
return ''
|
||||||
elseif info.patch
|
elseif info.patch
|
||||||
try
|
|
||||||
call s:StageApply(info, 1, info.section ==# 'Staged' ? ['--index'] : [])
|
call s:StageApply(info, 1, info.section ==# 'Staged' ? ['--index'] : [])
|
||||||
catch /^fugitive:/
|
elseif info.status ==# '?'
|
||||||
return 'echoerr ' . string(v:exception)
|
call s:TreeChomp('clean', '-f', '--', info.paths[0])
|
||||||
endtry
|
|
||||||
elseif a:count == 2
|
elseif a:count == 2
|
||||||
call s:TreeChomp('checkout', '--ours', '--', info.paths[0])
|
call s:TreeChomp('checkout', '--ours', '--', info.paths[0])
|
||||||
elseif a:count == 3
|
elseif a:count == 3
|
||||||
@ -2860,13 +2859,14 @@ function! s:StageDelete(lnum, count) abort
|
|||||||
call s:TreeChomp('rm', '--', info.paths[0])
|
call s:TreeChomp('rm', '--', info.paths[0])
|
||||||
elseif info.status ==# 'A'
|
elseif info.status ==# 'A'
|
||||||
call s:TreeChomp('rm', '-f', '--', info.paths[0])
|
call s:TreeChomp('rm', '-f', '--', info.paths[0])
|
||||||
elseif info.status ==# '?'
|
|
||||||
call s:TreeChomp('clean', '-f', '--', info.paths[0])
|
|
||||||
elseif info.section ==# 'Unstaged'
|
elseif info.section ==# 'Unstaged'
|
||||||
call s:TreeChomp('checkout', '--', info.paths[0])
|
call s:TreeChomp('checkout', '--', info.paths[0])
|
||||||
else
|
else
|
||||||
call s:TreeChomp('checkout', 'HEAD^{}', '--', info.paths[0])
|
call s:TreeChomp('checkout', 'HEAD^{}', '--', info.paths[0])
|
||||||
endif
|
endif
|
||||||
|
catch /^fugitive:/
|
||||||
|
return 'echoerr ' . string(v:exception)
|
||||||
|
endtry
|
||||||
exe s:ReloadStatus()
|
exe s:ReloadStatus()
|
||||||
call s:StageReveal()
|
call s:StageReveal()
|
||||||
let @@ = hash
|
let @@ = hash
|
||||||
|
Loading…
Reference in New Issue
Block a user