mirror of
https://github.com/tpope/vim-fugitive.git
synced 2025-11-11 12:53:52 -05:00
Accept alternate forms of Fugitive URL
This is to prepare for a potential transition to a URL replacement that isn't mutilated by simplify().
This commit is contained in:
@@ -428,7 +428,7 @@ call s:add_methods('repo',['keywordprg'])
|
|||||||
" Section: Buffer
|
" Section: Buffer
|
||||||
|
|
||||||
function! s:UrlSplit(path) abort
|
function! s:UrlSplit(path) abort
|
||||||
let vals = matchlist(s:shellslash(a:path), '\c^fugitive://\(.\{-\}\)//\(\w\+\)\(/.*\)\=$')
|
let vals = matchlist(s:shellslash(a:path), '\c^fugitive:\%(//\)\=\(.\{-\}\)\%(//\|::\)\(\w\+\)\(/.*\)\=$')
|
||||||
if empty(vals)
|
if empty(vals)
|
||||||
return ['', '', '']
|
return ['', '', '']
|
||||||
endif
|
endif
|
||||||
@@ -527,7 +527,7 @@ function! s:buffer_name() dict abort
|
|||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:buffer_commit() dict abort
|
function! s:buffer_commit() dict abort
|
||||||
return matchstr(self.spec(),'^fugitive://.\{-\}//\zs\w*')
|
return matchstr(self.spec(),'^fugitive:\%(//\)\=.\{-\}\%(//\|::\)\zs\w*')
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:cpath(path) abort
|
function! s:cpath(path) abort
|
||||||
@@ -539,7 +539,7 @@ function! s:cpath(path) abort
|
|||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:buffer_path(...) dict abort
|
function! s:buffer_path(...) dict abort
|
||||||
let rev = matchstr(self.spec(),'^fugitive://.\{-\}//\zs.*')
|
let rev = matchstr(self.spec(),'^fugitive:\%(//\)\=.\{-\}\%(//\|::\)\zs.*')
|
||||||
if rev != ''
|
if rev != ''
|
||||||
let rev = s:sub(rev,'\w*','')
|
let rev = s:sub(rev,'\w*','')
|
||||||
elseif s:cpath(self.spec()[0 : len(self.repo().dir())]) ==#
|
elseif s:cpath(self.spec()[0 : len(self.repo().dir())]) ==#
|
||||||
@@ -554,7 +554,7 @@ function! s:buffer_path(...) dict abort
|
|||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:buffer_rev() dict abort
|
function! s:buffer_rev() dict abort
|
||||||
let rev = matchstr(self.spec(),'^fugitive://.\{-\}//\zs.*')
|
let rev = matchstr(self.spec(),'^fugitive:\%(//\)\=.\{-\}\%(//\|::\)\zs.*')
|
||||||
if rev =~ '^\x/'
|
if rev =~ '^\x/'
|
||||||
return ':'.rev[0].':'.rev[2:-1]
|
return ':'.rev[0].':'.rev[2:-1]
|
||||||
elseif rev =~ '.'
|
elseif rev =~ '.'
|
||||||
@@ -569,7 +569,7 @@ function! s:buffer_rev() dict abort
|
|||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:buffer_sha1() dict abort
|
function! s:buffer_sha1() dict abort
|
||||||
if self.spec() =~ '^fugitive://' || self.spec() =~ '\.git/refs/\|\.git/.*HEAD$'
|
if self.spec() =~? '^fugitive:' || self.spec() =~ '\.git/refs/\|\.git/.*HEAD$'
|
||||||
return self.repo().rev_parse(self.rev())
|
return self.repo().rev_parse(self.rev())
|
||||||
else
|
else
|
||||||
return ''
|
return ''
|
||||||
@@ -2219,9 +2219,9 @@ function! s:Browse(bang,line1,count,...) abort
|
|||||||
endif
|
endif
|
||||||
let full = s:repo().translate(expanded)
|
let full = s:repo().translate(expanded)
|
||||||
let commit = ''
|
let commit = ''
|
||||||
if full =~# '^fugitive://'
|
if full =~? '^fugitive:'
|
||||||
let commit = matchstr(full,'://.*//\zs\w\w\+')
|
let commit = matchstr(full,':\%(//\)\=.*\%(//\|::\)\zs\w\w\+')
|
||||||
let path = matchstr(full,'://.*//\w\+\zs/.*')
|
let path = matchstr(full,':\%(//\)\=.*\%(//\|::\)\w\+\zs/.*')
|
||||||
if commit =~ '..'
|
if commit =~ '..'
|
||||||
let type = s:repo().git_chomp('cat-file','-t',commit.s:sub(path,'^/',':'))
|
let type = s:repo().git_chomp('cat-file','-t',commit.s:sub(path,'^/',':'))
|
||||||
let branch = matchstr(expanded, '^[^:]*')
|
let branch = matchstr(expanded, '^[^:]*')
|
||||||
@@ -2567,7 +2567,7 @@ endfunction
|
|||||||
function! fugitive#FileRead() abort
|
function! fugitive#FileRead() abort
|
||||||
try
|
try
|
||||||
let repo = s:repo(FugitiveExtractGitDir(expand('<amatch>')))
|
let repo = s:repo(FugitiveExtractGitDir(expand('<amatch>')))
|
||||||
let path = s:sub(s:sub(matchstr(expand('<amatch>'),'fugitive://.\{-\}//\zs.*'),'/',':'),'^\d:',':&')
|
let path = s:sub(s:sub(matchstr(expand('<amatch>'),'fugitive:\%(//\)\=.\{-\}\%(//\|::\)\zs.*'),'/',':'),'^\d:',':&')
|
||||||
let hash = repo.rev_parse(path)
|
let hash = repo.rev_parse(path)
|
||||||
if path =~ '^:'
|
if path =~ '^:'
|
||||||
let type = 'blob'
|
let type = 'blob'
|
||||||
|
|||||||
@@ -59,8 +59,8 @@ endfunction
|
|||||||
|
|
||||||
function! FugitiveExtractGitDir(path) abort
|
function! FugitiveExtractGitDir(path) abort
|
||||||
let path = s:shellslash(a:path)
|
let path = s:shellslash(a:path)
|
||||||
if path =~# '^fugitive://.*//'
|
if path =~# '^fugitive:'
|
||||||
return matchstr(path, '\C^fugitive://\zs.\{-\}\ze//')
|
return matchstr(path, '\C^fugitive:\%(//\)\=\zs.\{-\}\ze\%(//\|::\|$\)')
|
||||||
elseif isdirectory(path)
|
elseif isdirectory(path)
|
||||||
let path = fnamemodify(path, ':p:s?/$??')
|
let path = fnamemodify(path, ':p:s?/$??')
|
||||||
else
|
else
|
||||||
|
|||||||
Reference in New Issue
Block a user