mirror of
https://github.com/tpope/vim-fugitive.git
synced 2025-11-13 05:43:52 -05:00
Eliminate s:repo() and s:buffer()
This commit is contained in:
@@ -248,7 +248,7 @@ let s:abstract_prototype = {}
|
|||||||
let s:repo_prototype = {}
|
let s:repo_prototype = {}
|
||||||
let s:repos = {}
|
let s:repos = {}
|
||||||
|
|
||||||
function! s:repo(...) abort
|
function! fugitive#repo(...) abort
|
||||||
let dir = a:0 ? a:1 : (exists('b:git_dir') && b:git_dir !=# '' ? b:git_dir : FugitiveExtractGitDir(expand('%:p')))
|
let dir = a:0 ? a:1 : (exists('b:git_dir') && b:git_dir !=# '' ? b:git_dir : FugitiveExtractGitDir(expand('%:p')))
|
||||||
if dir !=# ''
|
if dir !=# ''
|
||||||
if has_key(s:repos, dir)
|
if has_key(s:repos, dir)
|
||||||
@@ -262,10 +262,6 @@ function! s:repo(...) abort
|
|||||||
call s:throw('not a git repository: '.expand('%:p'))
|
call s:throw('not a git repository: '.expand('%:p'))
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! fugitive#repo(...) abort
|
|
||||||
return call('s:repo', a:000)
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! s:repo_dir(...) dict abort
|
function! s:repo_dir(...) dict abort
|
||||||
return join([self.git_dir]+a:000,'/')
|
return join([self.git_dir]+a:000,'/')
|
||||||
endfunction
|
endfunction
|
||||||
@@ -341,7 +337,7 @@ function! s:repo_translate(spec, ...) dict abort
|
|||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:Generate(rev) abort
|
function! s:Generate(rev) abort
|
||||||
return s:repo().translate(a:rev, 1)
|
return fugitive#repo().translate(a:rev, 1)
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:repo_head(...) dict abort
|
function! s:repo_head(...) dict abort
|
||||||
@@ -741,7 +737,7 @@ endfunction
|
|||||||
|
|
||||||
let s:buffer_prototype = {}
|
let s:buffer_prototype = {}
|
||||||
|
|
||||||
function! s:buffer(...) abort
|
function! fugitive#buffer(...) abort
|
||||||
let buffer = {'#': bufnr(a:0 ? a:1 : '%')}
|
let buffer = {'#': bufnr(a:0 ? a:1 : '%')}
|
||||||
call extend(extend(buffer,s:buffer_prototype,'keep'),s:abstract_prototype,'keep')
|
call extend(extend(buffer,s:buffer_prototype,'keep'),s:abstract_prototype,'keep')
|
||||||
if buffer.getvar('git_dir') !=# ''
|
if buffer.getvar('git_dir') !=# ''
|
||||||
@@ -750,10 +746,6 @@ function! s:buffer(...) abort
|
|||||||
call s:throw('not a git repository: '.bufname(buffer['#']))
|
call s:throw('not a git repository: '.bufname(buffer['#']))
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! fugitive#buffer(...) abort
|
|
||||||
return s:buffer(a:0 ? a:1 : '%')
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! s:buffer_getvar(var) dict abort
|
function! s:buffer_getvar(var) dict abort
|
||||||
return getbufvar(self['#'],a:var)
|
return getbufvar(self['#'],a:var)
|
||||||
endfunction
|
endfunction
|
||||||
@@ -763,7 +755,7 @@ function! s:buffer_getline(lnum) dict abort
|
|||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:buffer_repo() dict abort
|
function! s:buffer_repo() dict abort
|
||||||
return s:repo(self.getvar('git_dir'))
|
return fugitive#repo(self.getvar('git_dir'))
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:buffer_type(...) dict abort
|
function! s:buffer_type(...) dict abort
|
||||||
@@ -2002,7 +1994,7 @@ endfunction
|
|||||||
|
|
||||||
function! s:Expand(rev) abort
|
function! s:Expand(rev) abort
|
||||||
if len(a:rev)
|
if len(a:rev)
|
||||||
return s:buffer().expand(a:rev)
|
return fugitive#buffer().expand(a:rev)
|
||||||
elseif expand('%') ==# ''
|
elseif expand('%') ==# ''
|
||||||
return ':'
|
return ':'
|
||||||
elseif empty(s:DirCommitFile(@%)[1]) && s:Relative('/') !~# '^/.git\>'
|
elseif empty(s:DirCommitFile(@%)[1]) && s:Relative('/') !~# '^/.git\>'
|
||||||
@@ -2910,7 +2902,7 @@ function! s:Browse(bang,line1,count,...) abort
|
|||||||
else
|
else
|
||||||
let expanded = s:Expand(rev)
|
let expanded = s:Expand(rev)
|
||||||
endif
|
endif
|
||||||
if filereadable(s:repo().dir('refs/tags/' . expanded))
|
if filereadable(b:git_dir . '/refs/tags/' . expanded)
|
||||||
let expanded = '.git/refs/tags/' . expanded
|
let expanded = '.git/refs/tags/' . expanded
|
||||||
endif
|
endif
|
||||||
let full = s:Generate(expanded)
|
let full = s:Generate(expanded)
|
||||||
@@ -3023,7 +3015,7 @@ function! s:Browse(bang,line1,count,...) abort
|
|||||||
|
|
||||||
let opts = {
|
let opts = {
|
||||||
\ 'dir': b:git_dir,
|
\ 'dir': b:git_dir,
|
||||||
\ 'repo': s:repo(),
|
\ 'repo': fugitive#repo(),
|
||||||
\ 'remote': raw,
|
\ 'remote': raw,
|
||||||
\ 'revision': 'No longer provided',
|
\ 'revision': 'No longer provided',
|
||||||
\ 'commit': commit,
|
\ 'commit': commit,
|
||||||
@@ -3377,7 +3369,7 @@ function! fugitive#head(...) abort
|
|||||||
return ''
|
return ''
|
||||||
endif
|
endif
|
||||||
|
|
||||||
return s:repo().head(a:0 ? a:1 : 0)
|
return fugitive#repo().head(a:0 ? a:1 : 0)
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
" Section: Folding
|
" Section: Folding
|
||||||
|
|||||||
Reference in New Issue
Block a user