parse out submodule path when not in a .git directory (#273).
This commit is contained in:
parent
d0c6ca4577
commit
a8c96b6020
@ -41,10 +41,18 @@ function! s:check_in_path()
|
|||||||
let root = get(b:, 'git_dir', get(b:, 'mercurial_dir', ''))
|
let root = get(b:, 'git_dir', get(b:, 'mercurial_dir', ''))
|
||||||
let bufferpath = resolve(fnamemodify(expand('%'), ':p:h'))
|
let bufferpath = resolve(fnamemodify(expand('%'), ':p:h'))
|
||||||
|
|
||||||
" .git may be a repo or a file depending on the version of git for submodules
|
if !filereadable(root) "not a file
|
||||||
if !filereadable(root)
|
" if .git is a directory, it's the old submodule format
|
||||||
|
if match(root, '\.git$') >= 0
|
||||||
let root = expand(fnamemodify(root, ':h'))
|
let root = expand(fnamemodify(root, ':h'))
|
||||||
|
else
|
||||||
|
" else it's the newer format, and we need to guesstimate
|
||||||
|
let pattern = '\.git\(\\\|\/\)modules\(\\\|\/\)'
|
||||||
|
if match(root, pattern) >= 0
|
||||||
|
let root = substitute(root, pattern, '', '')
|
||||||
endif
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
let b:airline_file_in_root = stridx(bufferpath, root) > -1
|
let b:airline_file_in_root = stridx(bufferpath, root) > -1
|
||||||
endif
|
endif
|
||||||
return b:airline_file_in_root
|
return b:airline_file_in_root
|
||||||
|
Loading…
Reference in New Issue
Block a user