Fix :Gblame when run from a subdirectory
This commit is contained in:
parent
61698761e5
commit
a5e10c932d
@ -662,11 +662,17 @@ function! s:Blame(bang,line1,line2,count) abort
|
|||||||
if strlen(s:buffer().commit()) == 40
|
if strlen(s:buffer().commit()) == 40
|
||||||
let cmd += [s:buffer().commit()]
|
let cmd += [s:buffer().commit()]
|
||||||
else
|
else
|
||||||
let cmd = ['--work-tree='.s:repo().tree()] + cmd + ['--contents', '-']
|
let cmd += ['--contents', '-']
|
||||||
endif
|
endif
|
||||||
let basecmd = call(s:repo().git_command,cmd+['--',s:buffer().path()],s:repo())
|
let basecmd = call(s:repo().git_command,cmd+['--',s:buffer().path()],s:repo())
|
||||||
|
try
|
||||||
|
let cd = exists('*haslocaldir') && haslocaldir() ? 'lcd ' : 'cd '
|
||||||
|
if !s:repo().bare()
|
||||||
|
let dir = getcwd()
|
||||||
|
execute cd.' `=s:repo().tree()`'
|
||||||
|
endif
|
||||||
if a:count
|
if a:count
|
||||||
return 'write !'.substitute(basecmd,' blame ',' blame -L '.a:line1.','.a:line2.' ','g')
|
execute 'write !'.substitute(basecmd,' blame ',' blame -L '.a:line1.','.a:line2.' ','g')
|
||||||
else
|
else
|
||||||
let temp = tempname().'.fugitiveblame'
|
let temp = tempname().'.fugitiveblame'
|
||||||
silent! exe '%write !'.basecmd.' > '.temp.' 2> '.temp
|
silent! exe '%write !'.basecmd.' > '.temp.' 2> '.temp
|
||||||
@ -704,6 +710,11 @@ function! s:Blame(bang,line1,line2,count) abort
|
|||||||
nnoremap <buffer> <silent> O :<C-U>exe <SID>Edit("tabedit", matchstr(getline('.'),'\x\+'))<CR>
|
nnoremap <buffer> <silent> O :<C-U>exe <SID>Edit("tabedit", matchstr(getline('.'),'\x\+'))<CR>
|
||||||
syncbind
|
syncbind
|
||||||
endif
|
endif
|
||||||
|
finally
|
||||||
|
if exists('l:dir')
|
||||||
|
execute cd.' `=dir`'
|
||||||
|
endif
|
||||||
|
endtry
|
||||||
return ''
|
return ''
|
||||||
catch /^fugitive:/
|
catch /^fugitive:/
|
||||||
return 'echoerr v:errmsg'
|
return 'echoerr v:errmsg'
|
||||||
|
Loading…
x
Reference in New Issue
Block a user