diff --git a/autoload/fugitive.vim b/autoload/fugitive.vim index 656be7a..4d4e2ee 100644 --- a/autoload/fugitive.vim +++ b/autoload/fugitive.vim @@ -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) diff --git a/plugin/fugitive.vim b/plugin/fugitive.vim index 348ab01..2f9dcf0 100644 --- a/plugin/fugitive.vim +++ b/plugin/fugitive.vim @@ -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