From 5aa8a3489eb02e4a4c9e572a5f86c8f42eb78d44 Mon Sep 17 00:00:00 2001 From: Tim Pope Date: Thu, 26 Aug 2021 09:04:30 -0400 Subject: [PATCH] Directly echo :Git output for a few trivial commands on Vim 7 If this works out, we can change the status buffer to directly call :Git rather than routing through FugitiveExecute(). --- autoload/fugitive.vim | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/autoload/fugitive.vim b/autoload/fugitive.vim index 452793e..ec819b6 100644 --- a/autoload/fugitive.vim +++ b/autoload/fugitive.vim @@ -2645,7 +2645,7 @@ function! fugitive#BufReadStatus() abort call s:Map('x', 's', ":execute Do('Stage',1)", '') call s:Map('n', 'u', ":execute Do('Unstage',0)", '') call s:Map('x', 'u', ":execute Do('Unstage',1)", '') - call s:Map('n', 'U', ":Git --no-pager reset -q", '') + call s:Map('n', 'U', ":Git reset -q", '') call s:MapMotion('gu', "exe StageJump(v:count, 'Untracked', 'Unstaged')") call s:MapMotion('gU', "exe StageJump(v:count, 'Unstaged', 'Untracked')") call s:MapMotion('gs', "exe StageJump(v:count, 'Staged')") @@ -3435,9 +3435,10 @@ function! fugitive#Command(line1, line2, range, bang, mods, arg) abort if pager is# -1 let pager = fugitive#PagerFor(args, config) endif - if type(pager) ==# type('') || - \ (s:HasOpt(args, ['add', 'checkout', 'commit', 'stage', 'stash', 'reset'], '-p', '--patch') || + let wants_terminal = type(pager) ==# type('') || + \ (s:HasOpt(args, ['add', 'checkout', 'commit', 'reset', 'restore', 'stage', 'stash'], '-p', '--patch') || \ s:HasOpt(args, ['add', 'clean', 'stage'], '-i', '--interactive')) && pager is# 0 + if wants_terminal let mods = substitute(s:Mods(a:mods), '\', '-tab', 'g') let assign = len(dir) ? '|let b:git_dir = ' . string(options.git_dir) : '' let argv = s:UserCommandList(options) + args @@ -3591,7 +3592,7 @@ function! fugitive#Command(line1, line2, range, bang, mods, arg) abort endif let cmd = s:BuildEnvPrefix(env) . s:shellesc(s:UserCommandList(options) + args) let after = '|call fugitive#ReloadStatus(' . string(dir) . ', 1)' . after - if no_pager + if !wants_terminal && (no_pager || index(['add', 'clean', 'reset', 'restore', 'stage'], get(args, 0, '')) >= 0 || s:HasOpt(args, ['checkout'], '-q', '--quiet', '--no-progress')) let output = substitute(s:SystemError(cmd)[0], "\n$", '', '') if len(output) try @@ -3599,7 +3600,7 @@ function! fugitive#Command(line1, line2, range, bang, mods, arg) abort let more = 1 set nomore endif - echo output + echo substitute(output, "\n$", "", "") finally if exists('l:more') set more