mirror of
https://github.com/tpope/vim-fugitive.git
synced 2025-11-12 05:13:53 -05:00
Extract helper for checking for same repository
This commit is contained in:
@@ -186,6 +186,11 @@ function! s:cpath(path, ...) abort
|
||||
return a:0 ? path ==# s:cpath(a:1) : path
|
||||
endfunction
|
||||
|
||||
function! s:SameRepo(one, two) abort
|
||||
let one = s:GitDir(a:one)
|
||||
return !empty(one) && one ==# s:GitDir(a:two)
|
||||
endfunction
|
||||
|
||||
let s:executables = {}
|
||||
|
||||
function! s:executable(binary) abort
|
||||
@@ -1631,7 +1636,7 @@ function! s:Owner(path, ...) abort
|
||||
endif
|
||||
let actualdir = fugitive#Find('.git/', dir)
|
||||
let [pdir, commit, file] = s:DirCommitFile(a:path)
|
||||
if s:cpath(s:GitDir(dir), s:GitDir(pdir))
|
||||
if s:SameRepo(dir, pdir)
|
||||
if commit =~# '^\x\{40,\}$'
|
||||
return commit
|
||||
elseif commit ==# '2'
|
||||
@@ -1682,8 +1687,9 @@ function! fugitive#Path(url, ...) abort
|
||||
if empty(a:url)
|
||||
return ''
|
||||
endif
|
||||
let dir = FugitiveVimPath(call('s:GitDir', a:000[1:-1]))
|
||||
let tree = call('fugitive#Find', [':/'] + a:000[1:-1])
|
||||
let repo = call('s:Dir', a:000[1:-1])
|
||||
let dir_s = fugitive#Find('.git/', repo)
|
||||
let tree = fugitive#Find(':/', repo)
|
||||
if !a:0
|
||||
return fugitive#Real(a:url)
|
||||
elseif a:1 =~# '\.$'
|
||||
@@ -1712,10 +1718,10 @@ function! fugitive#Path(url, ...) abort
|
||||
let url = url[0:-2]
|
||||
endif
|
||||
let [argdir, commit, file] = s:DirCommitFile(url)
|
||||
if !empty(argdir) && !s:cpath(s:GitDir(argdir), dir)
|
||||
if !empty(argdir) && !s:SameRepo(argdir, repo)
|
||||
let file = ''
|
||||
elseif len(dir) && s:cpath(url[0 : len(dir)]) ==# s:cpath(dir . '/')
|
||||
let file = '/.git'.url[strlen(dir) : -1]
|
||||
elseif len(dir_s) && s:cpath(strpart(url, 0, len(dir_s)), dir_s)
|
||||
let file = '/.git' . strpart(url, len(dir_s)-1)
|
||||
elseif len(tree) && s:cpath(url[0 : len(tree)]) ==# s:cpath(tree . '/')
|
||||
let file = url[len(tree) : -1]
|
||||
elseif s:cpath(url) ==# s:cpath(tree)
|
||||
@@ -1878,7 +1884,7 @@ endfunction
|
||||
function! fugitive#Object(...) abort
|
||||
let dir = a:0 > 1 ? s:Dir(a:2) : s:Dir()
|
||||
let [fdir, rev] = s:DirRev(a:0 ? a:1 : @%)
|
||||
if s:cpath(dir) !=# s:cpath(fdir)
|
||||
if !s:SameRepo(dir, fdir)
|
||||
let rev = ''
|
||||
endif
|
||||
let tree = s:Tree(dir)
|
||||
|
||||
Reference in New Issue
Block a user