mirror of
https://github.com/tpope/vim-fugitive.git
synced 2025-11-09 03:53:47 -05:00
Reduce noise on E211 from :Git
This commit is contained in:
@@ -739,9 +739,9 @@ endfunction
|
|||||||
|
|
||||||
function! s:cpath(path) abort
|
function! s:cpath(path) abort
|
||||||
if exists('+fileignorecase') && &fileignorecase
|
if exists('+fileignorecase') && &fileignorecase
|
||||||
return tolower(a:path)
|
return s:PlatformSlash(tolower(a:path))
|
||||||
else
|
else
|
||||||
return a:path
|
return s:PlatformSlash(a:path)
|
||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
@@ -832,17 +832,6 @@ call s:add_methods('buffer',['getvar','getline','repo','type','spec','name','com
|
|||||||
|
|
||||||
call s:command("-bang -nargs=? -complete=customlist,s:GitComplete Git :execute s:Git(<bang>0,'<mods>',<q-args>)")
|
call s:command("-bang -nargs=? -complete=customlist,s:GitComplete Git :execute s:Git(<bang>0,'<mods>',<q-args>)")
|
||||||
|
|
||||||
function! s:ExecuteInTree(cmd) abort
|
|
||||||
let cd = exists('*haslocaldir') && haslocaldir() ? 'lcd' : 'cd'
|
|
||||||
let dir = getcwd()
|
|
||||||
try
|
|
||||||
execute cd s:fnameescape(s:repo().tree())
|
|
||||||
execute a:cmd
|
|
||||||
finally
|
|
||||||
execute cd s:fnameescape(dir)
|
|
||||||
endtry
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! s:Git(bang, mods, args) abort
|
function! s:Git(bang, mods, args) abort
|
||||||
if a:bang
|
if a:bang
|
||||||
return s:Edit('edit', 1, a:mods, a:args)
|
return s:Edit('edit', 1, a:mods, a:args)
|
||||||
@@ -852,22 +841,27 @@ function! s:Git(bang, mods, args) abort
|
|||||||
let git .= ' --no-pager'
|
let git .= ' --no-pager'
|
||||||
endif
|
endif
|
||||||
let args = matchstr(a:args,'\v\C.{-}%($|\\@<!%(\\\\)*\|)@=')
|
let args = matchstr(a:args,'\v\C.{-}%($|\\@<!%(\\\\)*\|)@=')
|
||||||
|
let after = matchstr(a:args, '\v\C\\@<!%(\\\\)*\zs\|.*')
|
||||||
|
let tree = s:repo().tree()
|
||||||
|
if has('win32')
|
||||||
|
let after = '|call fugitive#ReloadStatus()' . after
|
||||||
|
endif
|
||||||
if exists(':terminal') && has('nvim') && !get(g:, 'fugitive_force_bang_command')
|
if exists(':terminal') && has('nvim') && !get(g:, 'fugitive_force_bang_command')
|
||||||
let dir = s:repo().tree()
|
|
||||||
if len(@%)
|
if len(@%)
|
||||||
-tabedit %
|
-tabedit %
|
||||||
else
|
else
|
||||||
-tabnew
|
-tabnew
|
||||||
endif
|
endif
|
||||||
execute 'lcd' fnameescape(dir)
|
execute 'lcd' fnameescape(tree)
|
||||||
execute 'terminal' git args
|
return 'exe ' .string('terminal ' . git . ' ' . args) . after
|
||||||
else
|
else
|
||||||
call s:ExecuteInTree('!'.git.' '.args)
|
let cmd = 'exe ' . string('!' . git . ' ' . args)
|
||||||
if has('win32')
|
if s:cpath(tree) !=# s:cpath(getcwd())
|
||||||
call fugitive#ReloadStatus()
|
let cd = exists('*haslocaldir') && haslocaldir() ? 'lcd' : 'cd'
|
||||||
|
let cmd = 'try|' . cd . ' ' . tree . '|' . cmd . '|finally|' . cd . ' ' . s:fnameescape(getcwd()) . '|endtry'
|
||||||
endif
|
endif
|
||||||
|
return cmd . after
|
||||||
endif
|
endif
|
||||||
return matchstr(a:args, '\v\C\\@<!%(\\\\)*\|\zs.*')
|
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:Subcommands() abort
|
function! s:Subcommands() abort
|
||||||
@@ -1569,7 +1563,14 @@ function! s:Edit(cmd, bang, mods, ...) abort
|
|||||||
if a:cmd =~# 'read'
|
if a:cmd =~# 'read'
|
||||||
let git = s:git_command()
|
let git = s:git_command()
|
||||||
let last = line('$')
|
let last = line('$')
|
||||||
silent call s:ExecuteInTree(mods.' '.(a:cmd ==# 'read' ? 'keepalt $read' : a:cmd).'!'.git.' --no-pager '.args)
|
let cd = exists('*haslocaldir') && haslocaldir() ? 'lcd' : 'cd'
|
||||||
|
let cwd = getcwd()
|
||||||
|
try
|
||||||
|
execute cd s:fnameescape(s:repo().tree())
|
||||||
|
silent execute mods.' '.(a:cmd ==# 'read' ? 'keepalt $read' : a:cmd).'!'.git.' --no-pager '.args
|
||||||
|
finally
|
||||||
|
execute cd s:fnameescape(cwd)
|
||||||
|
endtry
|
||||||
if a:cmd ==# 'read'
|
if a:cmd ==# 'read'
|
||||||
silent execute '1,'.last.'delete_'
|
silent execute '1,'.last.'delete_'
|
||||||
endif
|
endif
|
||||||
|
|||||||
Reference in New Issue
Block a user