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.
This commit is contained in:
Cimbali 2017-11-22 23:55:20 +01:00
parent 8c4bf37588
commit e415c5301f
1 changed files with 0 additions and 33 deletions

View File

@ -247,9 +247,6 @@ function! airline#extensions#branch#head()
endif endif
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 minwidth = empty(get(b:, 'airline_hunks', '')) ? 14 : 7
let b:airline_head = airline#util#shorten(b:airline_head, 120, minwidth) let b:airline_head = airline#util#shorten(b:airline_head, 120, minwidth)
return b:airline_head 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) \ : printf('%s%s', empty(symbol) ? '' : symbol.(g:airline_symbols.space), head)
endfunction 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) function! s:reset_untracked_cache(shellcmdpost)
" shellcmdpost - whether function was called as a result of ShellCmdPost hook " shellcmdpost - whether function was called as a result of ShellCmdPost hook
if !g:airline#init#vim_async && !has('nvim') if !g:airline#init#vim_async && !has('nvim')
@ -319,7 +287,6 @@ endfunction
function! airline#extensions#branch#init(ext) function! airline#extensions#branch#init(ext)
call airline#parts#define_function('branch', 'airline#extensions#branch#get_head') 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 ShellCmdPost,CmdwinLeave * unlet! b:airline_head b:airline_do_mq_check
autocmd User AirlineBeforeRefresh 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) autocmd BufWritePost * call s:reset_untracked_cache(0)