mirror of
https://github.com/tpope/vim-fugitive.git
synced 2025-11-12 21:33:53 -05:00
ReplaceCmd: redirect stderr to tmp file / buffer
The option `status.showUntrackedFiles=all` used with `git status` for
`:Gstatus` might cause an error, which then causes fugitive to display an
empty status window / index file.
Redirecting the stderr output is useful in this case.
The generated command was:
git --git-dir=/home/user/.dotfiles/.git -c 'status.displayCommentPrefix=true' -c 'color.status=false' -c 'status.short=false' -c 'status.showUntrackedFiles=all' status
The error from git is related to submodules being moved to another
subdirectory, where the relative "gitdir" now does not exist anymore:
fatal: Not a git repository: vim/bundle.old.nobackup/CLEAN/colorscheme-base16/../../../.git/modules/vim/bundle/colorscheme-base16
While that's a Git / user error after all, fugitive should be more
helpful in that case by displaying the error.
It uses the 'shellpipe' setting to detect if '2>&1' is supported (Ref:
https://github.com/tpope/vim-fugitive/pull/661#issuecomment-120438667).
Closes #661.
This commit is contained in:
@@ -2398,11 +2398,15 @@ function! s:ReplaceCmd(cmd,...) abort
|
|||||||
let prefix = 'env GIT_INDEX_FILE='.s:shellesc(a:1).' '
|
let prefix = 'env GIT_INDEX_FILE='.s:shellesc(a:1).' '
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
let redir = ' > '.tmp
|
||||||
|
if &shellpipe =~ '2>&1'
|
||||||
|
let redir .= ' 2>&1'
|
||||||
|
endif
|
||||||
if s:winshell()
|
if s:winshell()
|
||||||
let cmd_escape_char = &shellxquote == '(' ? '^' : '^^^'
|
let cmd_escape_char = &shellxquote == '(' ? '^' : '^^^'
|
||||||
call system('cmd /c "'.prefix.s:gsub(a:cmd,'[<>]', cmd_escape_char.'&').' > '.tmp.'"')
|
call system('cmd /c "'.prefix.s:gsub(a:cmd,'[<>]', cmd_escape_char.'&').redir.'"')
|
||||||
else
|
else
|
||||||
call system(' ('.prefix.a:cmd.' > '.tmp.') ')
|
call system(' ('.prefix.a:cmd.redir.') ')
|
||||||
endif
|
endif
|
||||||
finally
|
finally
|
||||||
if exists('old_index')
|
if exists('old_index')
|
||||||
|
|||||||
Reference in New Issue
Block a user