mirror of
https://github.com/vim-airline/vim-airline.git
synced 2025-07-25 23:14:50 +02:00
branch: simplify git branch logic slightly
This commit is contained in:
parent
91b67e3ca2
commit
e4f586b76b
@ -119,9 +119,6 @@ function! s:config_gina_branch() abort
|
|||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:display_git_branch()
|
function! s:display_git_branch()
|
||||||
" disable FocusGained autocommand, might cause loops because system() causes
|
|
||||||
" a refresh, which causes a system() command again #2029
|
|
||||||
call airline#util#ignore_next_focusgain()
|
|
||||||
let name = b:buffer_vcs_config['git'].branch
|
let name = b:buffer_vcs_config['git'].branch
|
||||||
try
|
try
|
||||||
let commit = matchstr(FugitiveParse()[0], '^\x\+')
|
let commit = matchstr(FugitiveParse()[0], '^\x\+')
|
||||||
@ -129,8 +126,15 @@ function! s:display_git_branch()
|
|||||||
if has_key(s:names, commit)
|
if has_key(s:names, commit)
|
||||||
let name = get(s:names, commit)."(".name.")"
|
let name = get(s:names, commit)."(".name.")"
|
||||||
elseif !empty(commit)
|
elseif !empty(commit)
|
||||||
let ref = fugitive#repo().git_chomp('describe', '--all', '--exact-match', commit)
|
if exists('*FugitiveExecute')
|
||||||
if ref !~ "^fatal: no tag exactly matches"
|
let ref = FugitiveExecute(['describe', '--all', '--exact-match', commit], bufnr('')).stdout[0]
|
||||||
|
else
|
||||||
|
noautocmd let ref = fugitive#repo().git_chomp('describe', '--all', '--exact-match', commit)
|
||||||
|
if ref =~# ':'
|
||||||
|
let ref = ''
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
if !empty(ref)
|
||||||
let name = s:format_name(substitute(ref, '\v\C^%(heads/|remotes/|tags/)=','',''))."(".name.")"
|
let name = s:format_name(substitute(ref, '\v\C^%(heads/|remotes/|tags/)=','',''))."(".name.")"
|
||||||
else
|
else
|
||||||
let name = matchstr(commit, '.\{'.s:sha1size.'}')."(".name.")"
|
let name = matchstr(commit, '.\{'.s:sha1size.'}')."(".name.")"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user