mirror of
https://github.com/tpope/vim-fugitive.git
synced 2025-11-14 22:33:51 -05:00
Pass --git-dir= alongside -C for nontrivial cases
References: https://github.com/tpope/vim-fugitive/issues/1796
This commit is contained in:
@@ -398,8 +398,13 @@ function! s:UserCommandList(...) abort
|
|||||||
let tree = s:Tree(dir)
|
let tree = s:Tree(dir)
|
||||||
if empty(tree)
|
if empty(tree)
|
||||||
call add(git, '--git-dir=' . FugitiveGitPath(dir))
|
call add(git, '--git-dir=' . FugitiveGitPath(dir))
|
||||||
elseif len(tree) && s:cpath(tree) !=# s:cpath(getcwd())
|
else
|
||||||
call extend(git, ['-C', FugitiveGitPath(tree)])
|
if !s:cpath(tree . '/.git', dir)
|
||||||
|
call add(git, '--git-dir=' . FugitiveGitPath(dir))
|
||||||
|
endif
|
||||||
|
if !s:cpath(tree, getcwd())
|
||||||
|
call extend(git, ['-C', FugitiveGitPath(tree)])
|
||||||
|
endif
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
return git + flags
|
return git + flags
|
||||||
@@ -638,11 +643,16 @@ function! s:PrepareJob(...) abort
|
|||||||
let tree = s:Tree(dir)
|
let tree = s:Tree(dir)
|
||||||
if empty(tree) || index(cmd, '--') == len(cmd) - 1
|
if empty(tree) || index(cmd, '--') == len(cmd) - 1
|
||||||
let dict.cwd = getcwd()
|
let dict.cwd = getcwd()
|
||||||
call extend(cmd, git + ['--git-dir=' . FugitiveGitPath(dir)], 'keep')
|
call extend(cmd, ['--git-dir=' . FugitiveGitPath(dir)], 'keep')
|
||||||
else
|
else
|
||||||
let dict.cwd = FugitiveVimPath(tree)
|
let dict.cwd = FugitiveVimPath(tree)
|
||||||
call extend(cmd, git + ['-C', FugitiveGitPath(tree)], 'keep')
|
call extend(cmd, ['-C', FugitiveGitPath(tree)], 'keep')
|
||||||
|
if !s:cpath(tree . '/.git', dir)
|
||||||
|
call extend(cmd, ['--git-dir=' . FugitiveGitPath(dir)], 'keep')
|
||||||
|
endif
|
||||||
endif
|
endif
|
||||||
|
call extend(cmd, git, 'keep')
|
||||||
|
let dict.full_argv = cmd
|
||||||
return s:JobOpts(cmd, exec_env) + [dict]
|
return s:JobOpts(cmd, exec_env) + [dict]
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
@@ -664,6 +674,9 @@ 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', dir)
|
||||||
|
call extend(cmd, ['--git-dir=' . FugitiveGitPath(dir)], 'keep')
|
||||||
|
endif
|
||||||
endif
|
endif
|
||||||
return pre . join(map(a:git + cmd, 's:shellesc(v:val)'))
|
return pre . join(map(a:git + cmd, 's:shellesc(v:val)'))
|
||||||
endfunction
|
endfunction
|
||||||
|
|||||||
Reference in New Issue
Block a user