Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit d1ac1f7

Browse files
committed
support hash-type branch name
1 parent d0b35a3 commit d1ac1f7

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

‎autoload/gitbranch.vim

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,22 @@
22
" Filename: autoload/gitbranch.vim
33
" Author: itchyny
44
" License: MIT License
5-
" Last Change: 2014/04/28 08:00:46.
5+
" Last Change: 2014/05/08 22:04:24.
66
" =============================================================================
77

88
let s:save_cpo = &cpo
99
set cpo&vim
1010

1111
function! gitbranch#name()
1212
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
1619
endif
20+
return ''
1721
endfunction
1822

1923
function! gitbranch#dir(path)

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /