mirror of
https://github.com/airblade/vim-gitgutter.git
synced 2025-11-09 12:03:48 -05:00
Move git-tracking check into diff command.
This avoids shelling out twice per buffer: once to check whether git knows about the file and once to perform the diff. Now we simply do both in one external call. Profiling showed external calls to git taking ~20ms. This doesn't seem too bad but it adds up.
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
let s:file = ''
|
||||
|
||||
function! utility#is_active()
|
||||
return g:gitgutter_enabled && utility#exists_file() && utility#is_tracked_by_git()
|
||||
return g:gitgutter_enabled && utility#exists_file()
|
||||
endfunction
|
||||
|
||||
function! utility#current_file()
|
||||
@@ -64,12 +64,6 @@ function! utility#command_in_directory_of_file(cmd)
|
||||
return substitute(utility#cmd_in_dir, "'", '"', 'g')
|
||||
endfunction
|
||||
|
||||
function! utility#is_tracked_by_git()
|
||||
let cmd = utility#escape('git ls-files --error-unmatch' . utility#discard_stdout_and_stderr() . ' ' . shellescape(utility#file()))
|
||||
call system(utility#command_in_directory_of_file(cmd))
|
||||
return !v:shell_error
|
||||
endfunction
|
||||
|
||||
function! utility#differences(hunks)
|
||||
return len(a:hunks) != 0
|
||||
endfunction
|
||||
|
||||
Reference in New Issue
Block a user