From 6860c592adb8d1f5df548689d3352e61224776b2 Mon Sep 17 00:00:00 2001 From: Tim Pope Date: Thu, 25 Mar 2021 20:03:41 -0400 Subject: [PATCH] Capture cwd of :Git command --- autoload/fugitive.vim | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/autoload/fugitive.vim b/autoload/fugitive.vim index 2245ac0..cbfaf62 100644 --- a/autoload/fugitive.vim +++ b/autoload/fugitive.vim @@ -218,6 +218,11 @@ endfunction " Section: Git +function! s:UserCommandCwd(dir) abort + let tree = s:Tree(a:dir) + return len(tree) ? FugitiveVimPath(tree) : getcwd() +endfunction + function! s:UserCommandList(...) abort let git = split(get(g:, 'fugitive_git_command', g:fugitive_git_executable), '\s\+') let flags = [] @@ -2688,6 +2693,8 @@ function! fugitive#Command(line1, line2, range, bang, mods, arg) abort \ 'flags': flags, \ 'args': args, \ 'dir': dir, + \ 'git_dir': dir, + \ 'cwd': s:UserCommandCwd(dir), \ 'filetype': 'git', \ 'mods': s:Mods(a:mods), \ 'file': s:Resolve(tempname())} @@ -5528,6 +5535,8 @@ function! s:BlameSubcommand(line1, count, range, bang, mods, options) abort \ 'flags': a:options.flags, \ 'args': [a:options.subcommand] + a:options.subcommand_args, \ 'dir': dir, + \ 'git_dir': dir, + \ 'cwd': s:UserCommandCwd(dir), \ 'filetype': (raw ? 'git' : 'fugitiveblame'), \ 'blame_options': a:options, \ '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) else 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 let mods = s:Mods(a:mods) if a:count != 0