Merge pull request #580 from andrewgregory/detached_head
use commit hash as git branch with detached HEAD
This commit is contained in:
commit
f17927053e
@ -21,7 +21,12 @@ function! s:get_git_branch(path)
|
|||||||
else
|
else
|
||||||
try
|
try
|
||||||
let line = join(readfile(dir . '/HEAD'))
|
let line = join(readfile(dir . '/HEAD'))
|
||||||
|
if strpart(line, 0, 16) == 'ref: refs/heads/'
|
||||||
let name = strpart(line, 16)
|
let name = strpart(line, 16)
|
||||||
|
else
|
||||||
|
" raw commit hash
|
||||||
|
let name = strpart(line, 0, 7)
|
||||||
|
endif
|
||||||
catch
|
catch
|
||||||
let name = ''
|
let name = ''
|
||||||
endtry
|
endtry
|
||||||
@ -39,7 +44,7 @@ function! airline#extensions#branch#head()
|
|||||||
let b:airline_head = ''
|
let b:airline_head = ''
|
||||||
|
|
||||||
if s:has_fugitive && !exists('b:mercurial_dir')
|
if s:has_fugitive && !exists('b:mercurial_dir')
|
||||||
let b:airline_head = fugitive#head()
|
let b:airline_head = fugitive#head(7)
|
||||||
|
|
||||||
if empty(b:airline_head) && !exists('b:git_dir')
|
if empty(b:airline_head) && !exists('b:git_dir')
|
||||||
let b:airline_head = s:get_git_branch(expand("%:p:h"))
|
let b:airline_head = s:get_git_branch(expand("%:p:h"))
|
||||||
|
Loading…
Reference in New Issue
Block a user