Decouple routing from repo object

This commit is contained in:
Tim Pope
2018-08-02 20:53:15 -04:00
parent f91c34069e
commit dd262b7e21
2 changed files with 86 additions and 72 deletions

View File

@@ -43,6 +43,10 @@ function! FugitiveReal(...) abort
endif
endfunction
function! FugitiveRoute(...) abort
return fugitive#Route(a:0 ? a:1 : '', FugitiveGitDir(a:0 > 1 ? a:2 : -1))
endfunction
function! FugitivePath(...) abort
if a:0 > 1
return fugitive#Path(a:1, a:2, FugitiveGitDir(a:0 > 2 ? a:3 : -1))
@@ -51,17 +55,6 @@ function! FugitivePath(...) abort
endif
endfunction
function! FugitiveGenerate(...) abort
if a:0 && s:Slash(a:1) =~# '^\%(\a\a\+:\)\=\%(a:\)\=/\|^[~$]'
return a:1
endif
return fugitive#repo(FugitiveGitDir(a:0 > 1 ? a:2 : -1)).translate(a:0 ? a:1 : '', 1)
endfunction
function! FugitiveRoute(...) abort
return call('FugitiveGenerate', a:000)
endfunction
function! FugitiveParse(...) abort
let path = s:Slash(a:0 ? a:1 : @%)
let vals = matchlist(path, '\c^fugitive:\%(//\)\=\(.\{-\}\)\%(//\|::\)\(\x\{40\}\|[0-3]\)\(/.*\)\=$')
@@ -207,6 +200,10 @@ function! FugitiveDetect(path) abort
endif
endfunction
function! FugitiveGenerate(...) abort
return call('FugitiveRoute', a:000)
endfunction
function! s:Slash(path) abort
if &shell =~? 'cmd' || exists('+shellslash') && !&shellslash
return tr(a:path, '\', '/')
@@ -239,7 +236,7 @@ augroup fugitive
autocmd FileType gitrebase
\ let &l:include = '^\%(pick\|squash\|edit\|reword\|fixup\|drop\|[pserfd]\)\>' |
\ if exists('b:git_dir') |
\ let &l:includeexpr = 'v:fname =~# ''^\x\{4,40\}$'' ? FugitiveGenerate(v:fname) : ' .
\ let &l:includeexpr = 'v:fname =~# ''^\x\{4,40\}$'' ? FugitiveRoute(v:fname) : ' .
\ (len(&l:includeexpr) ? &l:includeexpr : 'v:fname') |
\ endif |
\ let b:undo_ftplugin = get(b:, 'undo_ftplugin', 'exe') . '|setl inex= inc='