mirror of
https://github.com/tpope/vim-fugitive.git
synced 2025-11-08 11:33:47 -05:00
Move FugitiveParse() implementation into autoload file
Anticipating changes here, so let's try to avoid the dreaded "old plugin file loads new autoload file" edge case burning us.
This commit is contained in:
@@ -1626,6 +1626,10 @@ function! s:DirRev(url) abort
|
||||
return [dir, commit . file ==# '/.git/index' ? ':' : (!empty(dir) && commit =~# '^.$' ? ':' : '') . commit . substitute(file, '^/', ':', '')]
|
||||
endfunction
|
||||
|
||||
function! fugitive#Parse(url) abort
|
||||
return reverse(s:DirRev(a:url))
|
||||
endfunction
|
||||
|
||||
let s:merge_heads = ['MERGE_HEAD', 'REBASE_HEAD', 'CHERRY_PICK_HEAD', 'REVERT_HEAD']
|
||||
function! s:MergeHead(dir) abort
|
||||
let dir = fugitive#Find('.git/', a:dir)
|
||||
|
||||
@@ -91,12 +91,11 @@ function! FugitiveParse(...) abort
|
||||
if path !~# '^fugitive://'
|
||||
return ['', '']
|
||||
endif
|
||||
let vals = matchlist(path, s:dir_commit_file)
|
||||
if len(vals)
|
||||
return [(vals[2] =~# '^.\=$' ? ':' : '') . vals[2] . substitute(vals[3], '^/', ':', ''), vals[1]]
|
||||
let [rev, dir] = fugitive#Parse(path)
|
||||
if !empty(dir)
|
||||
return [rev, dir]
|
||||
endif
|
||||
let v:errmsg = 'fugitive: invalid Fugitive URL ' . path
|
||||
throw v:errmsg
|
||||
throw 'fugitive: invalid Fugitive URL ' . path
|
||||
endfunction
|
||||
|
||||
" FugitiveGitVersion() queries the version of Git in use. Pass up to 3
|
||||
@@ -430,7 +429,7 @@ function! FugitiveExtractGitDir(path) abort
|
||||
let path = s:Slash(a:path)
|
||||
endif
|
||||
if path =~# '^fugitive://'
|
||||
return get(matchlist(path, s:dir_commit_file), 1, '')
|
||||
return fugitive#Parse(path)[1]
|
||||
elseif empty(path)
|
||||
return ''
|
||||
endif
|
||||
@@ -486,8 +485,6 @@ endfunction
|
||||
|
||||
if exists('+shellslash')
|
||||
|
||||
let s:dir_commit_file = '\c^fugitive://\%(/\a\@=\)\=\(.\{-\}\)//\%(\(\x\{40,\}\|[0-3]\)\(/.*\)\=\)\=$'
|
||||
|
||||
function! s:Slash(path) abort
|
||||
return tr(a:path, '\', '/')
|
||||
endfunction
|
||||
@@ -502,8 +499,6 @@ if exists('+shellslash')
|
||||
|
||||
else
|
||||
|
||||
let s:dir_commit_file = '\c^fugitive://\(.\{-\}\)//\%(\(\x\{40,\}\|[0-3]\)\(/.*\)\=\)\=$'
|
||||
|
||||
function! s:Slash(path) abort
|
||||
return a:path
|
||||
endfunction
|
||||
|
||||
Reference in New Issue
Block a user