commit a03444404a3710a1427e34883deedd5669acab21 (tree)
parent 64a3f99d0305ef673c51a8c27963aaaf0de3d1b7
Author: Tim Pope <code@tpope.net>
Date: Sat, 20 Mar 2021 03:48:46 -0400
Capture exit status of :Git
Diffstat:
1 file changed, 16 insertions(+), 0 deletions(-)
diff --git a/autoload/fugitive.vim b/autoload/fugitive.vim
@@ -2414,10 +2414,24 @@ function! s:RunReceive(state, tmp, type, job, data, ...) abort
echon substitute(data, "\r\\ze\n", '', 'g')
endfunction
+function! s:RunExit(state, tmp, job, exit_status) abort
+ let a:state.exit_status = a:exit_status
+ if has_key(a:state, 'job')
+ return
+ endif
+ call s:RunFinished(a:state)
+endfunction
+
function! s:RunClose(state, tmp, job, ...) abort
+ if a:0
+ call s:RunExit(a:state, a:tmp, a:job, a:1)
+ endif
let noeol = substitute(substitute(a:tmp.err, "\r$", '', ''), ".*\r", '', '') . a:tmp.out
call writefile([noeol], a:state.file, 'ba')
call remove(a:state, 'job')
+ if !has_key(a:state, 'exit_status')
+ return
+ endif
call s:RunFinished(a:state)
endfunction
@@ -2700,6 +2714,7 @@ function! fugitive#Command(line1, line2, range, bang, mods, arg) abort
\ 'out_cb': function('s:RunReceive', [state, tmp, 'out']),
\ 'err_cb': function('s:RunReceive', [state, tmp, 'err']),
\ 'close_cb': function('s:RunClose', [state, tmp]),
+ \ 'exit_cb': function('s:RunExit', [state, tmp]),
\ })
if state.pty
let jobopts.pty = 1
@@ -2721,6 +2736,7 @@ function! fugitive#Command(line1, line2, range, bang, mods, arg) abort
let pre = s:BuildEnvPrefix(env)
silent! execute '!' . escape(pre . s:UserCommand({'git': git, 'dir': dir}, s:disable_colors + flags + ['--no-pager'] + args), '!#%') .
\ (&shell =~# 'csh' ? ' >& ' . s:shellesc(state.file) : ' > ' . s:shellesc(state.file) . ' 2>&1')
+ let state.exit_status = v:shell_error
redraw!
call s:RunSave(state)
call s:RunFinished(state)