commit 80cd9c876e56c70135643601fe08e30010eb88dc (tree)
parent 8165eada59fb78502ba5dd0f3b3fd01285db834f
Author: Tim Pope <code@tpope.net>
Date: Thu, 23 Jun 2022 18:05:03 -0400
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.
Diffstat:
2 files changed, 9 insertions(+), 10 deletions(-)
diff --git 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
@@ -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