Skip to content

Commit

Permalink
expose cleaner api to determine empty head.
Browse files Browse the repository at this point in the history
  • Loading branch information
bling committed Dec 3, 2013
1 parent ed7111b commit 0966b69
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
9 changes: 8 additions & 1 deletion autoload/airline/extensions/branch.vim
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ let s:empty_message = get(g:, 'airline#extensions#branch#empty_message',
\ get(g:, 'airline_branch_empty_message', ''))
let s:symbol = get(g:, 'airline#extensions#branch#symbol', g:airline_symbols.branch)

function! airline#extensions#branch#get_head()
function! airline#extensions#branch#head()
let head = ''

if s:has_fugitive && !exists('b:mercurial_dir')
Expand Down Expand Up @@ -42,6 +42,13 @@ function! airline#extensions#branch#get_head()
endif

return empty(head) || !s:check_in_path()
\ ? ''
\ : head
endfunction

function! airline#extensions#branch#get_head()
let head = airline#extensions#branch#head()
return empty(head)
\ ? s:empty_message
\ : printf('%s%s', empty(s:symbol) ? '' : s:symbol.(g:airline_symbols.space), head)
endfunction
Expand Down
9 changes: 6 additions & 3 deletions autoload/airline/extensions/hunks.vim
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,13 @@ function! s:get_hunks_signify()
return []
endfunction

function! s:is_branch_empty()
return get(g:, 'airline#extensions#branch#enabled', 1) && empty(airline#extensions#branch#head())
endfunction

function! s:get_hunks_gitgutter()
if !get(g:, 'gitgutter_enabled', 0) || airline#extensions#branch#get_head() ==
\ get(g:, 'airline#extensions#branch#empty_message', get(g:, 'airline_branch_empty_message', ''))
return ''
if !get(g:, 'gitgutter_enabled', 0) || s:is_branch_empty()
return ''
endif
return GitGutterGetHunkSummary()
endfunction
Expand Down

0 comments on commit 0966b69

Please sign in to comment.