|
2 | 2 | " Filename: autoload/gitbranch.vim
|
3 | 3 | " Author: itchyny
|
4 | 4 | " License: MIT License
|
5 | | -" Last Change: 2014/04/28 08:00:46. |
| 5 | +" Last Change: 2014/05/08 22:04:24. |
6 | 6 | " =============================================================================
|
7 | 7 |
|
8 | 8 | let s:save_cpo = &cpo
|
9 | 9 | set cpo&vim
|
10 | 10 |
|
11 | 11 | function! gitbranch#name()
|
12 | 12 | if has_key(b:, 'gitbranch_path')
|
13 | | - return substitute(get(readfile(b:gitbranch_path), 0, ''), '^ref: \%(refs/\%(heads/\|remotes/\|tags/\)\=\)\=', '', '') |
14 | | - else |
15 | | - return '' |
| 13 | + let branch = get(readfile(b:gitbranch_path), 0, '') |
| 14 | + if branch =~# '^ref' |
| 15 | + return substitute(branch, '^ref: \%(refs/\%(heads/\|remotes/\|tags/\)\=\)\=', '', '') |
| 16 | + elseif branch =~# '^\x\{20\}' |
| 17 | + return branch[:6] |
| 18 | + endif |
16 | 19 | endif
|
| 20 | + return '' |
17 | 21 | endfunction
|
18 | 22 |
|
19 | 23 | function! gitbranch#dir(path)
|
|
0 commit comments