mirror of
https://github.com/tpope/vim-fugitive.git
synced 2025-11-12 13:23:52 -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)
|
if empty(tree)
|
||||||
call add(git, '--git-dir=' . FugitiveGitPath(dir))
|
call add(git, '--git-dir=' . FugitiveGitPath(dir))
|
||||||
else
|
else
|
||||||
if !s:cpath(tree . '/.git', dir)
|
if !s:cpath(tree . '/.git', dir) || len($GIT_DIR)
|
||||||
call add(git, '--git-dir=' . FugitiveGitPath(dir))
|
call add(git, '--git-dir=' . FugitiveGitPath(dir))
|
||||||
endif
|
endif
|
||||||
if !s:cpath(tree, getcwd())
|
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))
|
let a:env['GIT_INDEX_FILE'] = FugitiveGitPath(fugitive#Find('.git/index', a:dir))
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
if len($GIT_WORK_TREE)
|
||||||
|
let a:env['GIT_WORK_TREE'] = '.'
|
||||||
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
let s:prepare_env = {
|
let s:prepare_env = {
|
||||||
@@ -712,7 +715,7 @@ function! fugitive#PrepareJob(...) abort
|
|||||||
else
|
else
|
||||||
let dict.cwd = FugitiveVimPath(tree)
|
let dict.cwd = FugitiveVimPath(tree)
|
||||||
call extend(cmd, ['-C', FugitiveGitPath(tree)], 'keep')
|
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')
|
call extend(cmd, ['--git-dir=' . FugitiveGitPath(dir)], 'keep')
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
@@ -750,7 +753,7 @@ function! s:BuildShell(dir, env, git, args) abort
|
|||||||
call insert(cmd, '--git-dir=' . FugitiveGitPath(a:dir))
|
call insert(cmd, '--git-dir=' . FugitiveGitPath(a:dir))
|
||||||
else
|
else
|
||||||
call extend(cmd, ['-C', FugitiveGitPath(tree)], 'keep')
|
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')
|
call extend(cmd, ['--git-dir=' . FugitiveGitPath(a:dir)], 'keep')
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
|||||||
Reference in New Issue
Block a user