mirror of
https://github.com/tpope/vim-fugitive.git
synced 2025-11-09 12:03:47 -05:00
Use :Git --no-pager in Vim 7 to directly echo output
At long last we will have a way to directly invoke :Git from inside various status maps without subjecting Vim 7 users to a press enter prompt.
This commit is contained in:
@@ -337,6 +337,8 @@ endfunction
|
|||||||
|
|
||||||
" Section: Git
|
" Section: Git
|
||||||
|
|
||||||
|
let s:run_jobs = (exists('*job_start') || exists('*jobstart')) && exists('*bufwinid')
|
||||||
|
|
||||||
function! s:GitCmd() abort
|
function! s:GitCmd() abort
|
||||||
if !exists('g:fugitive_git_executable')
|
if !exists('g:fugitive_git_executable')
|
||||||
return ['git']
|
return ['git']
|
||||||
@@ -862,16 +864,6 @@ function! s:StdoutToFile(out, cmd, ...) abort
|
|||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:EchoExec(...) abort
|
|
||||||
if s:RunJobs()
|
|
||||||
return 'Git ' . s:fnameescape(a:000)
|
|
||||||
else
|
|
||||||
echo substitute(s:SystemError(call('fugitive#ShellCommand', a:000))[0], "\n$", '', '')
|
|
||||||
call fugitive#ReloadStatus(-1, 1)
|
|
||||||
return 'checktime'
|
|
||||||
endif
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
let s:head_cache = {}
|
let s:head_cache = {}
|
||||||
|
|
||||||
function! fugitive#Head(...) abort
|
function! fugitive#Head(...) abort
|
||||||
@@ -2600,7 +2592,7 @@ function! fugitive#BufReadStatus() abort
|
|||||||
call s:Map('x', 's', ":<C-U>execute <SID>Do('Stage',1)<CR>", '<silent>')
|
call s:Map('x', 's', ":<C-U>execute <SID>Do('Stage',1)<CR>", '<silent>')
|
||||||
call s:Map('n', 'u', ":<C-U>execute <SID>Do('Unstage',0)<CR>", '<silent>')
|
call s:Map('n', 'u', ":<C-U>execute <SID>Do('Unstage',0)<CR>", '<silent>')
|
||||||
call s:Map('x', 'u', ":<C-U>execute <SID>Do('Unstage',1)<CR>", '<silent>')
|
call s:Map('x', 'u', ":<C-U>execute <SID>Do('Unstage',1)<CR>", '<silent>')
|
||||||
call s:Map('n', 'U', ":exe <SID>EchoExec('reset', '-q')<CR>", '<silent>')
|
call s:Map('n', 'U', "Git --no-pager reset -q<CR>", '<silent>')
|
||||||
call s:MapMotion('gu', "exe <SID>StageJump(v:count, 'Untracked', 'Unstaged')")
|
call s:MapMotion('gu', "exe <SID>StageJump(v:count, 'Untracked', 'Unstaged')")
|
||||||
call s:MapMotion('gU', "exe <SID>StageJump(v:count, 'Unstaged', 'Untracked')")
|
call s:MapMotion('gU', "exe <SID>StageJump(v:count, 'Unstaged', 'Untracked')")
|
||||||
call s:MapMotion('gs', "exe <SID>StageJump(v:count, 'Staged')")
|
call s:MapMotion('gs', "exe <SID>StageJump(v:count, 'Staged')")
|
||||||
@@ -2953,10 +2945,6 @@ function! s:AskPassArgs(dir) abort
|
|||||||
return []
|
return []
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:RunJobs() abort
|
|
||||||
return (exists('*job_start') || exists('*jobstart')) && exists('*bufwinid')
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! s:RunSave(state) abort
|
function! s:RunSave(state) abort
|
||||||
let s:temp_files[s:cpath(a:state.file)] = a:state
|
let s:temp_files[s:cpath(a:state.file)] = a:state
|
||||||
endfunction
|
endfunction
|
||||||
@@ -3433,7 +3421,7 @@ function! fugitive#Command(line1, line2, range, bang, mods, arg) abort
|
|||||||
endif
|
endif
|
||||||
call extend(env, {'COLUMNS': '' . get(g:, 'fugitive_columns', 80)}, 'keep')
|
call extend(env, {'COLUMNS': '' . get(g:, 'fugitive_columns', 80)}, 'keep')
|
||||||
endif
|
endif
|
||||||
if s:RunJobs()
|
if s:run_jobs
|
||||||
call extend(env, {'COLUMNS': '' . (&columns - 1)}, 'keep')
|
call extend(env, {'COLUMNS': '' . (&columns - 1)}, 'keep')
|
||||||
let state.pty = allow_pty && get(g:, 'fugitive_pty', has('unix') && !has('win32unix') && (has('patch-8.0.0744') || has('nvim')) && fugitive#GitVersion() !~# '\.windows\>')
|
let state.pty = allow_pty && get(g:, 'fugitive_pty', has('unix') && !has('win32unix') && (has('patch-8.0.0744') || has('nvim')) && fugitive#GitVersion() !~# '\.windows\>')
|
||||||
if !state.pty
|
if !state.pty
|
||||||
@@ -3535,10 +3523,30 @@ function! fugitive#Command(line1, line2, range, bang, mods, arg) abort
|
|||||||
elseif has('gui_running')
|
elseif has('gui_running')
|
||||||
return 'echoerr ' . string('fugitive: Vim 8 with job support required to use :Git in GVim')
|
return 'echoerr ' . string('fugitive: Vim 8 with job support required to use :Git in GVim')
|
||||||
else
|
else
|
||||||
let pre = s:BuildEnvPrefix(env)
|
if !explicit_pathspec_option && get(options.flags, 0, '') ==# '--no-literal-pathspecs'
|
||||||
return 'exe ' . string('noautocmd !' . escape(pre . s:shellesc(s:UserCommandList(options) + args), '!#%')) .
|
call remove(options.flags, 0)
|
||||||
\ '|call fugitive#ReloadStatus(' . string(dir) . ', 1)' .
|
endif
|
||||||
\ after
|
let cmd = s:BuildEnvPrefix(env) . s:shellesc(s:UserCommandList(options) + args)
|
||||||
|
let after = '|call fugitive#ReloadStatus(' . string(dir) . ', 1)' . after
|
||||||
|
if no_pager
|
||||||
|
let output = substitute(s:SystemError(cmd)[0], "\n$", '', '')
|
||||||
|
if len(output)
|
||||||
|
try
|
||||||
|
if &more
|
||||||
|
let more = 1
|
||||||
|
set nomore
|
||||||
|
endif
|
||||||
|
echo output
|
||||||
|
finally
|
||||||
|
if exists('l:more')
|
||||||
|
set more
|
||||||
|
endif
|
||||||
|
endtry
|
||||||
|
endif
|
||||||
|
return 'silent checktime' . after
|
||||||
|
else
|
||||||
|
return 'exe ' . string('noautocmd !' . escape(cmd, '!#%')) . after
|
||||||
|
endif
|
||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user