Skip to content

Commit

Permalink
Stop early when file is in .git directory.
Browse files Browse the repository at this point in the history
  • Loading branch information
airblade committed Mar 23, 2015
1 parent 1a7f1c5 commit 8345c35
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion autoload/gitgutter/utility.vim
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,14 @@ function! gitgutter#utility#warn(message)
let v:warningmsg = a:message
endfunction

" Returns truthy when the buffer's file should be processed; and falsey when it shouldn't.
" This function does not and should not make any system calls.
function! gitgutter#utility#is_active()
return g:gitgutter_enabled && gitgutter#utility#exists_file()
return g:gitgutter_enabled && gitgutter#utility#exists_file() && gitgutter#utility#not_git_dir()
endfunction

function! gitgutter#utility#not_git_dir()
return gitgutter#utility#full_path_to_directory_of_file() !~ '\.git\([/\\].*\)\?$'
endfunction

" A replacement for the built-in `shellescape(arg)`.
Expand Down Expand Up @@ -51,6 +57,10 @@ function! gitgutter#utility#extension()
return fnamemodify(s:file, ':e')
endfunction

function! gitgutter#utility#full_path_to_directory_of_file()
return fnamemodify(s:file, ':p:h')
endfunction

function! gitgutter#utility#directory_of_file()
return fnamemodify(s:file, ':h')
endfunction
Expand Down

0 comments on commit 8345c35

Please sign in to comment.