Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Inform git of correct directory via --git-dir.

This avoids all the nastiness of changing directories back and forth.

Fixes #10.
  • Loading branch information...
commit 8e1857a86fad34e940bc2388ece957ab33c0f621 1 parent 1906606
@int3 authored
Showing with 7 additions and 15 deletions.
  1. +7 −15 plugin/extradite.vim
View
22 plugin/extradite.vim
@@ -50,15 +50,6 @@ 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_autochdir = &autochdir
- set noautochdir
- let b:stashed_dir = getcwd()
- let b:git_tree_dir = fugitive#buffer().repo().tree()
- execute b:cd.' '.b:git_tree_dir
- autocmd BufEnter <buffer> exe b:cd.' '.b:git_tree_dir
- autocmd BufLeave <buffer> exe b:cd.' '.getbufvar('<afile>','stashed_dir')
autocmd BufEnter <buffer> call s:ExtraditeSyntax()
autocmd BufLeave <buffer> hi! link CursorLine NONE
autocmd BufLeave <buffer> hi! link Cursor NONE
@@ -77,6 +68,7 @@ function! s:ExtraditeLoadCommitData(bang, base_file_name, template_cmd, ...) abo
let path = ''
endif
+ let git_cmd = fugitive#buffer().repo().git_command()
let cmd = a:template_cmd + ['--pretty=format:\%an \%d \%s', '--', path]
let basecmd = call(fugitive#buffer().repo().git_command,cmd,fugitive#buffer().repo())
let extradata_cmd = a:template_cmd + ['--pretty=format:%h %ad', '--', path]
@@ -107,6 +99,7 @@ function! s:ExtraditeLoadCommitData(bang, base_file_name, template_cmd, ...) abo
" this must happen after we create the Extradite buffer so that
" b:extradata_list gets placed in the right buffer
+ let b:git_cmd = git_cmd
let extradata_str = system(extradata_basecmd)
let extradata = split(extradata_str, '\n')
let b:extradata_list = []
@@ -148,7 +141,6 @@ function! s:ExtraditeClose() abort
if exists('b:extradite_simplediff_bufnr') && bufwinnr(b:extradite_simplediff_bufnr) >= 0
exe 'keepjumps bd!' . b:extradite_simplediff_bufnr
endif
- exe 'set '.(b:stashed_autochdir ? '' : 'no').'autochdir'
keepjumps bd
let logged_winnr = bufwinnr(extradite_logged_bufnr)
if logged_winnr >= 0
@@ -187,7 +179,7 @@ endfunction
function! s:ExtraditeDiffToggle() abort
if !exists('b:extradite_simplediff_bufnr') || b:extradite_simplediff_bufnr == -1
augroup extradite
- autocmd CursorMoved <buffer> call s:SimpleFileDiff(s:ExtraditePath('~1'), s:ExtraditePath())
+ autocmd CursorMoved <buffer> call s:SimpleFileDiff(b:git_cmd,s:ExtraditePath('~1'), s:ExtraditePath())
" vim seems to get confused if we jump around buffers during a CursorMoved event. Moving the cursor
" around periodically helps vim figure out where it should really be.
autocmd CursorHold <buffer> normal! lh
@@ -201,8 +193,8 @@ endfunction
" Does a git diff on a single file and discards the top few lines of extraneous
" information
-function! s:SimpleFileDiff(a,b) abort
- call s:SimpleDiff(a:a,a:b)
+function! s:SimpleFileDiff(git_cmd,a,b) abort
+ call s:SimpleDiff(a:git_cmd,a:a,a:b)
let win = bufwinnr(b:extradite_simplediff_bufnr)
exe 'keepjumps '.win.'wincmd w'
setlocal modifiable
@@ -213,7 +205,7 @@ endfunction
" Does a git diff of commits a and b. Will create one simplediff-buffer that is
" unique wrt the buffer that it is invoked from.
-function! s:SimpleDiff(a,b) abort
+function! s:SimpleDiff(git_cmd,a,b) abort
if !exists('b:extradite_simplediff_bufnr') || b:extradite_simplediff_bufnr == -1
belowright split
@@ -237,7 +229,7 @@ function! s:SimpleDiff(a,b) abort
setlocal modifiable
silent! %delete _
- let diff = system('git diff '.a:a.' '.a:b)
+ let diff = system(a:git_cmd.' diff '.a:a.' '.a:b)
silent put = diff
setlocal ft=diff buftype=nofile nomodifiable
Please sign in to comment.
Something went wrong with that request. Please try again.