From 50cf1b3bd110f8c25b3b89029630989af7f5faa5 Mon Sep 17 00:00:00 2001 From: John Drouhard Date: Wed, 23 Jan 2019 13:42:51 -0600 Subject: [PATCH] Fix s:Cd() usage in the Gblame command Most usages in commit da3b2f32 (Support tab local working directories) were updated to use this pattern, but Gblame missed the boat. Without this, Gblame will change the root git tree but won't change back to the previous location. --- autoload/fugitive.vim | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/autoload/fugitive.vim b/autoload/fugitive.vim index 0e0cb00..f1f3818 100644 --- a/autoload/fugitive.vim +++ b/autoload/fugitive.vim @@ -3549,13 +3549,7 @@ function! s:Blame(bang, line1, line2, count, mods, args) abort let cmd += ['--', expand('%:p')] let basecmd = escape(fugitive#Prepare(cmd), '!#%') try - let cd = s:Cd() - let tree = s:Tree() - let cdback = s:Cd(tree) - if len(tree) && s:cpath(tree) !=# s:cpath(getcwd()) - let cwd = getcwd() - execute cd s:fnameescape(tree) - endif + let cdback = s:Cd(s:Tree()) let error = tempname() let temp = error.'.fugitiveblame' if &shell =~# 'csh' @@ -3563,10 +3557,10 @@ function! s:Blame(bang, line1, line2, count, mods, args) abort else silent! execute '%write !'.basecmd.' > '.temp.' 2> '.error endif - if exists('l:cwd') - execute cd s:fnameescape(cwd) - unlet cwd - endif + finally + execute cdback + endtry + try if v:shell_error call s:throw(join(readfile(error),"\n")) endif @@ -3639,10 +3633,6 @@ function! s:Blame(bang, line1, line2, count, mods, args) abort redraw syncbind endif - finally - if exists('l:cwd') - execute cd s:fnameescape(cwd) - endif endtry return '' catch /^fugitive:/