Skip to content

Commit

Permalink
cd to git directory in file log view.
Browse files Browse the repository at this point in the history
This ensures that the diff view works even if vim was not launched from
the git directory.
  • Loading branch information
int3 committed Mar 18, 2011
1 parent 2291cab commit 09b2a75
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions plugin/extradite.vim
Expand Up @@ -50,6 +50,13 @@ function! s:Extradite(bang) abort
" doesn't seem to work
nnoremap <buffer> <silent> t :let line=line('.')<cr> :<C-U>exe <SID>ExtraditeDiffToggle()<CR> :exe line<cr>
autocmd CursorMoved <buffer> exe 'setlocal statusline='.escape(b:extradata_list[line(".")-1]['date'], ' ')
" cd to git repo so system() calls to git work
let b:cd = exists('*haslocaldir') && haslocaldir() ? 'lcd ' : 'cd '
let b:stashed_dir = getcwd()
let b:git_dir = fugitive#buffer().repo().tree()
execute b:cd.' '.b:git_dir
autocmd BufEnter <buffer> exe b:cd.' '.b:git_dir
autocmd BufLeave <buffer> exe b:cd.' '.getbufvar('<afile>','stashed_dir')
call s:ExtraditeDiffToggle()
let g:extradite_bufnr = bufnr('')
return ''
Expand Down

0 comments on commit 09b2a75

Please sign in to comment.