From e415c5301f1ba1c53fac8308d1d2e8c8f4b348ba Mon Sep 17 00:00:00 2001 From: Cimbali Date: Wed, 22 Nov 2017 23:55:20 +0100 Subject: [PATCH] Trusting fugitive instead of tracking paths manually The initial reason in #237 is not valid anymore, as vim-gitgutter functions as expected for editing files that are not part of a repo, whether they are: - in a different repo - in a parent repo (cwd being a submodule) - outside of the repo Furthermore, removing this check allows to show relevant info for specific fugitive file names that are fugitive://..../sha1//... which are hard to parse manually, especially in complicated situations such as submodules. --- autoload/airline/extensions/branch.vim | 33 -------------------------- 1 file changed, 33 deletions(-) diff --git a/autoload/airline/extensions/branch.vim b/autoload/airline/extensions/branch.vim index c46c3c51..b85c155f 100644 --- a/autoload/airline/extensions/branch.vim +++ b/autoload/airline/extensions/branch.vim @@ -247,9 +247,6 @@ function! airline#extensions#branch#head() endif endif - if has_key(heads, 'git') && !s:check_in_path() - let b:airline_head = '' - endif let minwidth = empty(get(b:, 'airline_hunks', '')) ? 14 : 7 let b:airline_head = airline#util#shorten(b:airline_head, 120, minwidth) return b:airline_head @@ -264,35 +261,6 @@ function! airline#extensions#branch#get_head() \ : printf('%s%s', empty(symbol) ? '' : symbol.(g:airline_symbols.space), head) endfunction -function! s:check_in_path() - if !exists('b:airline_file_in_root') - let root = get(b:, 'git_dir', get(b:, 'mercurial_dir', '')) - let bufferpath = resolve(fnamemodify(expand('%'), ':p')) - - if !filereadable(root) "not a file - " if .git is a directory, it's the old submodule format - if match(root, '\.git$') >= 0 - let root = expand(fnamemodify(root, ':h')) - else - " else it's the newer format, and we need to guesstimate - " 1) check for worktrees - if match(root, 'worktrees') > -1 - " worktree can be anywhere, so simply assume true here - return 1 - endif - " 2) check for submodules - let pattern = '\.git[\\/]\(modules\)[\\/]' - if match(root, pattern) >= 0 - let root = substitute(root, pattern, '', '') - endif - endif - endif - - let b:airline_file_in_root = stridx(bufferpath, root) > -1 - endif - return b:airline_file_in_root -endfunction - function! s:reset_untracked_cache(shellcmdpost) " shellcmdpost - whether function was called as a result of ShellCmdPost hook if !g:airline#init#vim_async && !has('nvim') @@ -319,7 +287,6 @@ endfunction function! airline#extensions#branch#init(ext) call airline#parts#define_function('branch', 'airline#extensions#branch#get_head') - autocmd BufReadPost * unlet! b:airline_file_in_root autocmd ShellCmdPost,CmdwinLeave * unlet! b:airline_head b:airline_do_mq_check autocmd User AirlineBeforeRefresh unlet! b:airline_head b:airline_do_mq_check autocmd BufWritePost * call s:reset_untracked_cache(0)