mirror of
https://github.com/tpope/vim-fugitive.git
synced 2025-11-12 05:13:53 -05:00
Don't trust git --version with nonzero exit status
This prevents parsing `zsh:1: command not found: git` as version "1:". References: https://github.com/tpope/vim-fugitive/issues/1801
This commit is contained in:
@@ -321,7 +321,8 @@ let s:git_versions = {}
|
||||
function! fugitive#GitVersion(...) abort
|
||||
let git = s:GitShellCmd()
|
||||
if !has_key(s:git_versions, git)
|
||||
let s:git_versions[git] = matchstr(s:SystemError(s:GitCmd() + ['--version'])[0], '\d[^[:space:]]\+')
|
||||
let [out, exec_error] = s:SystemError(s:GitCmd() + ['--version'])
|
||||
let s:git_versions[git] = exec_error ? '' : matchstr(out, '\d[^[:space:]]\+')
|
||||
endif
|
||||
if !a:0
|
||||
return s:git_versions[git]
|
||||
|
||||
Reference in New Issue
Block a user