mirror of
https://github.com/tpope/vim-fugitive.git
synced 2025-11-12 05:13:53 -05:00
Try to avoid interference by $GIT_DIR and $GIT_WORK_TREE
Resolves: https://github.com/tpope/vim-fugitive/issues/1841
This commit is contained in:
@@ -428,7 +428,7 @@ function! s:UserCommandList(...) abort
|
||||
if empty(tree)
|
||||
call add(git, '--git-dir=' . FugitiveGitPath(dir))
|
||||
else
|
||||
if !s:cpath(tree . '/.git', dir)
|
||||
if !s:cpath(tree . '/.git', dir) || len($GIT_DIR)
|
||||
call add(git, '--git-dir=' . FugitiveGitPath(dir))
|
||||
endif
|
||||
if !s:cpath(tree, getcwd())
|
||||
@@ -555,6 +555,9 @@ function! s:PrepareEnv(env, dir) abort
|
||||
let a:env['GIT_INDEX_FILE'] = FugitiveGitPath(fugitive#Find('.git/index', a:dir))
|
||||
endif
|
||||
endif
|
||||
if len($GIT_WORK_TREE)
|
||||
let a:env['GIT_WORK_TREE'] = '.'
|
||||
endif
|
||||
endfunction
|
||||
|
||||
let s:prepare_env = {
|
||||
@@ -712,7 +715,7 @@ function! fugitive#PrepareJob(...) abort
|
||||
else
|
||||
let dict.cwd = FugitiveVimPath(tree)
|
||||
call extend(cmd, ['-C', FugitiveGitPath(tree)], 'keep')
|
||||
if !s:cpath(tree . '/.git', dir)
|
||||
if !s:cpath(tree . '/.git', dir) || len($GIT_DIR)
|
||||
call extend(cmd, ['--git-dir=' . FugitiveGitPath(dir)], 'keep')
|
||||
endif
|
||||
endif
|
||||
@@ -750,7 +753,7 @@ function! s:BuildShell(dir, env, git, args) abort
|
||||
call insert(cmd, '--git-dir=' . FugitiveGitPath(a:dir))
|
||||
else
|
||||
call extend(cmd, ['-C', FugitiveGitPath(tree)], 'keep')
|
||||
if !s:cpath(tree . '/.git', a:dir)
|
||||
if !s:cpath(tree . '/.git', a:dir) || len($GIT_DIR)
|
||||
call extend(cmd, ['--git-dir=' . FugitiveGitPath(a:dir)], 'keep')
|
||||
endif
|
||||
endif
|
||||
|
||||
Reference in New Issue
Block a user