Capture cwd of :Git command

This commit is contained in:
Tim Pope
2021-03-25 20:03:41 -04:00
parent a12e88bcc2
commit 6860c592ad

View File

@@ -218,6 +218,11 @@ endfunction
" Section: Git " Section: Git
function! s:UserCommandCwd(dir) abort
let tree = s:Tree(a:dir)
return len(tree) ? FugitiveVimPath(tree) : getcwd()
endfunction
function! s:UserCommandList(...) abort function! s:UserCommandList(...) abort
let git = split(get(g:, 'fugitive_git_command', g:fugitive_git_executable), '\s\+') let git = split(get(g:, 'fugitive_git_command', g:fugitive_git_executable), '\s\+')
let flags = [] let flags = []
@@ -2688,6 +2693,8 @@ function! fugitive#Command(line1, line2, range, bang, mods, arg) abort
\ 'flags': flags, \ 'flags': flags,
\ 'args': args, \ 'args': args,
\ 'dir': dir, \ 'dir': dir,
\ 'git_dir': dir,
\ 'cwd': s:UserCommandCwd(dir),
\ 'filetype': 'git', \ 'filetype': 'git',
\ 'mods': s:Mods(a:mods), \ 'mods': s:Mods(a:mods),
\ 'file': s:Resolve(tempname())} \ 'file': s:Resolve(tempname())}
@@ -5528,6 +5535,8 @@ function! s:BlameSubcommand(line1, count, range, bang, mods, options) abort
\ 'flags': a:options.flags, \ 'flags': a:options.flags,
\ 'args': [a:options.subcommand] + a:options.subcommand_args, \ 'args': [a:options.subcommand] + a:options.subcommand_args,
\ 'dir': dir, \ 'dir': dir,
\ 'git_dir': dir,
\ 'cwd': s:UserCommandCwd(dir),
\ 'filetype': (raw ? 'git' : 'fugitiveblame'), \ 'filetype': (raw ? 'git' : 'fugitiveblame'),
\ 'blame_options': a:options, \ 'blame_options': a:options,
\ 'blame_flags': flags, \ 'blame_flags': flags,
@@ -5540,7 +5549,8 @@ function! s:BlameSubcommand(line1, count, range, bang, mods, options) abort
return s:BlameCommit(edit, get(readfile(temp), 0, ''), temp_state) return s:BlameCommit(edit, get(readfile(temp), 0, ''), temp_state)
else else
let temp = s:Resolve(temp) let temp = s:Resolve(temp)
let s:temp_files[s:cpath(temp)] = temp_state let temp_state.file = temp
call s:RunSave(temp_state)
if len(ranges + commits + files) || raw if len(ranges + commits + files) || raw
let mods = s:Mods(a:mods) let mods = s:Mods(a:mods)
if a:count != 0 if a:count != 0