Provide API for retrieving working dir relative path
This commit is contained in:
parent
a202238b5d
commit
44e5df8433
@ -474,15 +474,33 @@ function! fugitive#Real(url) abort
|
|||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! fugitive#Path(url, ...) abort
|
function! fugitive#Path(url, ...) abort
|
||||||
if !a:0 || empty(a:url)
|
if empty(a:url)
|
||||||
|
return ''
|
||||||
|
endif
|
||||||
|
let dir = a:0 > 1 ? a:2 : get(b:, 'git_dir', '')
|
||||||
|
let tree = s:Tree(dir)
|
||||||
|
if !a:0
|
||||||
return fugitive#Real(a:url)
|
return fugitive#Real(a:url)
|
||||||
|
elseif a:1 =~# '\.$'
|
||||||
|
let path = s:Slash(fugitive#Real(a:url))
|
||||||
|
let cwd = getcwd()
|
||||||
|
let lead = ''
|
||||||
|
while s:cpath(tree . '/', (cwd . '/')[0 : len(tree)])
|
||||||
|
if s:cpath(cwd . '/', path[0 : len(cwd)])
|
||||||
|
if strpart(path, len(cwd) + 1) =~# '^\.git\%(/\|$\)'
|
||||||
|
break
|
||||||
|
endif
|
||||||
|
return a:1[0:-2] . (empty(lead) ? './' : lead) . strpart(path, len(cwd) + 1)
|
||||||
|
endif
|
||||||
|
let cwd = fnamemodify(cwd, ':h')
|
||||||
|
let lead .= '../'
|
||||||
|
endwhile
|
||||||
|
return a:1[0:-2] . path
|
||||||
endif
|
endif
|
||||||
let url = s:Slash(fnamemodify(a:url, ':p'))
|
let url = s:Slash(fnamemodify(a:url, ':p'))
|
||||||
if url =~# '/$' && s:Slash(a:url) !~# '/$'
|
if url =~# '/$' && s:Slash(a:url) !~# '/$'
|
||||||
let url = url[0:-2]
|
let url = url[0:-2]
|
||||||
endif
|
endif
|
||||||
let dir = a:0 > 1 ? a:2 : get(b:, 'git_dir', '')
|
|
||||||
let tree = s:Tree(dir)
|
|
||||||
let [argdir, commit, file] = s:DirCommitFile(a:url)
|
let [argdir, commit, file] = s:DirCommitFile(a:url)
|
||||||
if len(argdir) && s:cpath(argdir) !=# s:cpath(dir)
|
if len(argdir) && s:cpath(argdir) !=# s:cpath(dir)
|
||||||
let file = ''
|
let file = ''
|
||||||
@ -2187,10 +2205,10 @@ function! s:Log(cmd, bang, line1, line2, ...) abort
|
|||||||
let before = substitute(args, ' --\S\@!.*', '', '')
|
let before = substitute(args, ' --\S\@!.*', '', '')
|
||||||
let after = strpart(args, len(before))
|
let after = strpart(args, len(before))
|
||||||
let path = s:Relative('/')
|
let path = s:Relative('/')
|
||||||
|
let relative = path[1:-1]
|
||||||
if path =~# '^/\.git\%(/\|$\)' || len(after)
|
if path =~# '^/\.git\%(/\|$\)' || len(after)
|
||||||
let path = ''
|
let path = ''
|
||||||
endif
|
endif
|
||||||
let relative = s:Relative('')
|
|
||||||
if before !~# '\s[^[:space:]-]'
|
if before !~# '\s[^[:space:]-]'
|
||||||
let owner = s:Owner(@%)
|
let owner = s:Owner(@%)
|
||||||
if len(owner)
|
if len(owner)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user