From 8c4bf37588fb52f0aa3237d491d81f74061140c1 Mon Sep 17 00:00:00 2001 From: Cimbali Date: Wed, 22 Nov 2017 22:41:00 +0100 Subject: [PATCH] Configurability: parametrizable sha1 length --- autoload/airline/extensions/branch.vim | 5 +++-- doc/airline.txt | 3 +++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/autoload/airline/extensions/branch.vim b/autoload/airline/extensions/branch.vim index 7e9625bd..c46c3c51 100644 --- a/autoload/airline/extensions/branch.vim +++ b/autoload/airline/extensions/branch.vim @@ -84,6 +84,7 @@ endif " Fugitive special revisions. call '0' "staging" ? let s:names = {'0': 'index', '1': 'ancestor', '2':'target', '3':'merged'} +let s:sha1size = get(g:, 'airline#extensions#branch#sha1_len', 7) function! s:update_git_branch() if !s:has_fugitive @@ -91,7 +92,7 @@ function! s:update_git_branch() return endif - let name = fugitive#head(7) + let name = fugitive#head(s:sha1size) try let commit = fugitive#buffer().commit() @@ -103,7 +104,7 @@ function! s:update_git_branch() if ref !~ "^fatal: no tag exactly matches" let name = s:format_name(substitute(ref, '\v\C^%(heads/|remotes/|tags/)=','',''))."(".name.")" else - let name = commit[:6]."(".name.")" + let name = commit[0:s:sha1size-1]."(".name.")" endif endif catch diff --git a/doc/airline.txt b/doc/airline.txt index 051b5d2f..c9c65785 100644 --- a/doc/airline.txt +++ b/doc/airline.txt @@ -453,6 +453,9 @@ notexists symbol will be displayed after the branch name. return '[' . a:name . ']' endfunction < +* truncate sha1 commits at this number of characters > + let g:airline#extensions#branch#sha1_len = 10 +< ------------------------------------- *airline-syntastic* syntastic