From d4a239f14aefce88c1558423a2e4ee21651720a4 Mon Sep 17 00:00:00 2001 From: Christian Brabandt Date: Wed, 23 Nov 2016 16:30:02 +0100 Subject: [PATCH 1/2] Make airline aware of git worktrees Currently vim-airline assumes, that the git_dir is part of the path for the file being edited. This has changed, since git supports worktrees. So take care of b:git_dir (which is set by fugitive) being a path differently from the absolute path of the file being edited (however, it should include the substring worktree in that case). --- autoload/airline/extensions/branch.vim | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/autoload/airline/extensions/branch.vim b/autoload/airline/extensions/branch.vim index 9c911b9c..580439ba 100644 --- a/autoload/airline/extensions/branch.vim +++ b/autoload/airline/extensions/branch.vim @@ -351,7 +351,13 @@ function! s:check_in_path() let root = expand(fnamemodify(root, ':h')) else " else it's the newer format, and we need to guesstimate - let pattern = '\.git\(\\\|\/\)modules\(\\\|\/\)' + " 1) check for worktrees + if match(root, 'worktrees') > -1 + " worktree can be anywhere, so simply assume true here + return 1 + endif + " 2) check for submodules + let pattern = '\.git[\\/]\(modules\)[\\/]' if match(root, pattern) >= 0 let root = substitute(root, pattern, '', '') endif From b67509189b1a7135baa3ffebef3e293a087d636a Mon Sep 17 00:00:00 2001 From: Christian Brabandt Date: Wed, 23 Nov 2016 16:31:32 +0100 Subject: [PATCH 2/2] check for correct variable --- autoload/airline/extensions/branch.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/autoload/airline/extensions/branch.vim b/autoload/airline/extensions/branch.vim index 580439ba..56fd32e6 100644 --- a/autoload/airline/extensions/branch.vim +++ b/autoload/airline/extensions/branch.vim @@ -341,7 +341,7 @@ function! airline#extensions#branch#get_head() endfunction function! s:check_in_path() - if !exists('b:airline_branch_path') + if !exists('b:airline_file_in_root') let root = get(b:, 'git_dir', get(b:, 'mercurial_dir', '')) let bufferpath = resolve(fnamemodify(expand('%'), ':p'))