Encapsulate b:git_dir

This commit is contained in:
Tim Pope
2019-02-25 17:10:54 -05:00
parent 0171b2a5b0
commit b44b7b8ae7
2 changed files with 77 additions and 70 deletions

View File

@@ -29,7 +29,7 @@ function! FugitiveCommonDir(...) abort
endfunction
function! FugitiveWorkTree(...) abort
return FugitiveTreeForGitDir(FugitiveGitDir(a:0 ? a:1 : -1))
return s:Tree(FugitiveGitDir(a:0 ? a:1 : -1))
endfunction
function! FugitiveReal(...) abort
@@ -110,7 +110,7 @@ endfunction
let s:worktree_for_dir = {}
let s:dir_for_worktree = {}
function! FugitiveTreeForGitDir(path) abort
function! s:Tree(path) abort
let dir = a:path
if dir =~# '/\.git$'
return len(dir) ==# 5 ? '/' : dir[0:-6]
@@ -173,7 +173,7 @@ function! FugitiveExtractGitDir(path) abort
return simplify(fnamemodify($GIT_DIR, ':p:s?[\/]$??'))
endif
if FugitiveIsGitDir($GIT_DIR)
call FugitiveWorkTree(simplify(fnamemodify($GIT_DIR, ':p:s?[\/]$??')))
call s:Tree(simplify(fnamemodify($GIT_DIR, ':p:s?[\/]$??')))
if has_key(s:dir_for_worktree, root)
return s:dir_for_worktree[root]
endif
@@ -228,7 +228,7 @@ function! s:ProjectionistDetect() abort
let dir = FugitiveExtractGitDir(file)
let base = matchstr(file, '^fugitive://.\{-\}//\x\+')
if empty(base)
let base = FugitiveTreeForGitDir(dir)
let base = s:Tree(dir)
endif
if len(base)
if exists('+shellslash') && !&shellslash
@@ -251,21 +251,21 @@ augroup fugitive
autocmd CmdWinEnter * call FugitiveDetect(expand('#:p'))
autocmd FileType git
\ if exists('b:git_dir') |
\ if len(FugitiveGitDir()) |
\ call fugitive#MapJumps() |
\ call fugitive#MapCfile() |
\ endif
autocmd FileType gitcommit
\ if exists('b:git_dir') |
\ if len(FugitiveGitDir()) |
\ call fugitive#MapCfile('fugitive#MessageCfile()') |
\ endif
autocmd FileType fugitive
\ if exists('b:git_dir') |
\ if len(FugitiveGitDir()) |
\ call fugitive#MapCfile('fugitive#StatusCfile()') |
\ endif
autocmd FileType gitrebase
\ let &l:include = '^\%(pick\|squash\|edit\|reword\|fixup\|drop\|[pserfd]\)\>' |
\ if exists('b:git_dir') |
\ if len(FugitiveGitDir()) |
\ let &l:includeexpr = 'v:fname =~# ''^\x\{4,40\}$'' ? FugitiveFind(v:fname) : ' .
\ (len(&l:includeexpr) ? &l:includeexpr : 'v:fname') |
\ endif |