mirror of
https://github.com/tpope/vim-fugitive.git
synced 2025-11-13 22:03:51 -05:00
Accept both fugitive://C:/ and fugitive:///C:/ on win32
The 2 slash version slots the drive letter into the host field, which I'm worried will cause problems when the URLs are used non-opaquely, for example, with an LSP. Let's start transitioning to the convention used by file:// URLs.
This commit is contained in:
@@ -139,10 +139,12 @@ function! s:Mods(mods, ...) abort
|
|||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
if exists('+shellslash')
|
if exists('+shellslash')
|
||||||
|
let s:dir_commit_file = '\c^fugitive://\%(/\a\@=\)\=\(.\{-\}\)//\%(\(\x\{40,\}\|[0-3]\)\(/.*\)\=\)\=$'
|
||||||
function! s:Slash(path) abort
|
function! s:Slash(path) abort
|
||||||
return tr(a:path, '\', '/')
|
return tr(a:path, '\', '/')
|
||||||
endfunction
|
endfunction
|
||||||
else
|
else
|
||||||
|
let s:dir_commit_file = '\c^fugitive://\(.\{-\}\)//\%(\(\x\{40,\}\|[0-3]\)\(/.*\)\=\)\=$'
|
||||||
function! s:Slash(path) abort
|
function! s:Slash(path) abort
|
||||||
return a:path
|
return a:path
|
||||||
endfunction
|
endfunction
|
||||||
@@ -1606,7 +1608,7 @@ call s:add_methods('repo',['config', 'user'])
|
|||||||
" Section: File API
|
" Section: File API
|
||||||
|
|
||||||
function! s:DirCommitFile(path) abort
|
function! s:DirCommitFile(path) abort
|
||||||
let vals = matchlist(s:Slash(a:path), '\c^fugitive://\(.\{-\}\)//\%(\(\x\{40,\}\|[0-3]\)\(/.*\)\=\)\=$')
|
let vals = matchlist(s:Slash(a:path), s:dir_commit_file)
|
||||||
if empty(vals)
|
if empty(vals)
|
||||||
return ['', '', '']
|
return ['', '', '']
|
||||||
endif
|
endif
|
||||||
|
|||||||
@@ -88,10 +88,10 @@ endfunction
|
|||||||
" the inverse of FugitiveFind().
|
" the inverse of FugitiveFind().
|
||||||
function! FugitiveParse(...) abort
|
function! FugitiveParse(...) abort
|
||||||
let path = s:Slash(a:0 ? a:1 : @%)
|
let path = s:Slash(a:0 ? a:1 : @%)
|
||||||
if path !~# '^fugitive:'
|
if path !~# '^fugitive://'
|
||||||
return ['', '']
|
return ['', '']
|
||||||
endif
|
endif
|
||||||
let vals = matchlist(path, '\c^fugitive://\(.\{-\}\)//\%(\(\x\{40,\}\|[0-3]\)\(/.*\)\=\)\=$')
|
let vals = matchlist(path, s:dir_commit_file)
|
||||||
if len(vals)
|
if len(vals)
|
||||||
return [(vals[2] =~# '^.\=$' ? ':' : '') . vals[2] . substitute(vals[3], '^/', ':', ''), vals[1]]
|
return [(vals[2] =~# '^.\=$' ? ':' : '') . vals[2] . substitute(vals[3], '^/', ':', ''), vals[1]]
|
||||||
endif
|
endif
|
||||||
@@ -412,8 +412,8 @@ function! FugitiveExtractGitDir(path) abort
|
|||||||
else
|
else
|
||||||
let path = s:Slash(a:path)
|
let path = s:Slash(a:path)
|
||||||
endif
|
endif
|
||||||
if path =~# '^fugitive:'
|
if path =~# '^fugitive://'
|
||||||
return matchstr(path, '\C^fugitive:\%(//\)\=\zs.\{-\}\ze\%(//\|::\|$\)')
|
return get(matchlist(path, s:dir_commit_file), 1, '')
|
||||||
elseif empty(path)
|
elseif empty(path)
|
||||||
return ''
|
return ''
|
||||||
else
|
else
|
||||||
@@ -509,10 +509,12 @@ function! FugitiveGitPath(path) abort
|
|||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
if exists('+shellslash')
|
if exists('+shellslash')
|
||||||
|
let s:dir_commit_file = '\c^fugitive://\%(/\a\@=\)\=\(.\{-\}\)//\%(\(\x\{40,\}\|[0-3]\)\(/.*\)\=\)\=$'
|
||||||
function! s:Slash(path) abort
|
function! s:Slash(path) abort
|
||||||
return tr(a:path, '\', '/')
|
return tr(a:path, '\', '/')
|
||||||
endfunction
|
endfunction
|
||||||
else
|
else
|
||||||
|
let s:dir_commit_file = '\c^fugitive://\(.\{-\}\)//\%(\(\x\{40,\}\|[0-3]\)\(/.*\)\=\)\=$'
|
||||||
function! s:Slash(path) abort
|
function! s:Slash(path) abort
|
||||||
return a:path
|
return a:path
|
||||||
endfunction
|
endfunction
|
||||||
@@ -521,7 +523,7 @@ endif
|
|||||||
function! s:ProjectionistDetect() abort
|
function! s:ProjectionistDetect() abort
|
||||||
let file = s:Slash(get(g:, 'projectionist_file', ''))
|
let file = s:Slash(get(g:, 'projectionist_file', ''))
|
||||||
let dir = FugitiveExtractGitDir(file)
|
let dir = FugitiveExtractGitDir(file)
|
||||||
let base = matchstr(file, '^fugitive://.\{-\}//\x\+')
|
let base = get(matchlist(file, s:dir_commit_file), 1, '')
|
||||||
if empty(base)
|
if empty(base)
|
||||||
let base = s:Tree(dir)
|
let base = s:Tree(dir)
|
||||||
endif
|
endif
|
||||||
|
|||||||
Reference in New Issue
Block a user