Provide FugitiveGenerate() and FugitiveParse()

This commit is contained in:
Tim Pope
2018-07-22 01:29:49 -04:00
parent 1e41a88ec9
commit 71acb7da35
2 changed files with 38 additions and 20 deletions

View File

@@ -152,6 +152,20 @@ function! FugitiveReal(...) abort
return call('FugitivePath', a:000)
endfunction
function! FugitiveGenerate(...) abort
return fugitive#repo(a:0 > 1 ? a:2 : get(b:, 'git_dir', '')).translate(a:0 ? a:1 : '', 1)
endfunction
function! FugitiveParse(...) abort
let path = s:shellslash(a:0 ? a:1 : @%)
let vals = matchlist(path, '\c^fugitive:\%(//\)\=\(.\{-\}\)\%(//\|::\)\(\x\{40\}\|[0-3]\)\(/.*\)\=$')
if len(vals)
return [(vals[2] =~# '^.$' ? ':' : '') . vals[2] . substitute(vals[3], '^/', ':', ''), vals[1]]
endif
let v:errmsg = 'fugitive: invalid Fugitive URL ' . path
throw v:errmsg
endfunction
augroup fugitive
autocmd!