Rename s:shellslash() to s:Slash()

This commit is contained in:
Tim Pope
2018-07-30 01:35:11 -04:00
parent 81deb6333a
commit c85980cd93
2 changed files with 25 additions and 25 deletions

View File

@@ -8,21 +8,13 @@ if exists('g:loaded_fugitive')
endif
let g:loaded_fugitive = 1
function! s:shellslash(path) abort
if &shell =~? 'cmd' || exists('+shellslash') && !&shellslash
return tr(a:path, '\', '/')
else
return a:path
endif
endfunction
function! FugitiveGitDir(...) abort
if !a:0 || a:1 ==# -1
return get(b:, 'git_dir', '')
elseif type(a:1) == type(0)
return getbufvar(a:1, 'git_dir')
elseif type(a:1) == type('')
return substitute(s:shellslash(a:1), '/$', '', '')
return substitute(s:Slash(a:1), '/$', '', '')
else
return ''
endif
@@ -60,7 +52,7 @@ function! FugitivePath(...) abort
endfunction
function! FugitiveGenerate(...) abort
if a:0 && s:shellslash(a:1) =~# '^\%(\a\a\+:\)\=\%(a:\)\=/\|^[~$]'
if a:0 && s:Slash(a:1) =~# '^\%(\a\a\+:\)\=\%(a:\)\=/\|^[~$]'
return a:1
endif
return fugitive#repo(FugitiveGitDir(a:0 > 1 ? a:2 : -1)).translate(a:0 ? a:1 : '', 1)
@@ -71,7 +63,7 @@ function! FugitiveRoute(...) abort
endfunction
function! FugitiveParse(...) abort
let path = s:shellslash(a:0 ? a:1 : @%)
let path = s:Slash(a:0 ? a:1 : @%)
let vals = matchlist(path, '\c^fugitive:\%(//\)\=\(.\{-\}\)\%(//\|::\)\(\x\{40\}\|[0-3]\)\(/.*\)\=$')
if len(vals)
return [(vals[2] =~# '^.$' ? ':' : '') . vals[2] . substitute(vals[3], '^/', ':', ''), vals[1]]
@@ -145,7 +137,7 @@ function! FugitiveTreeForGitDir(path) abort
endfunction
function! FugitiveExtractGitDir(path) abort
let path = s:shellslash(a:path)
let path = s:Slash(a:path)
if path =~# '^fugitive:'
return matchstr(path, '\C^fugitive:\%(//\)\=\zs.\{-\}\ze\%(//\|::\|$\)')
elseif isdirectory(path)
@@ -155,7 +147,7 @@ function! FugitiveExtractGitDir(path) abort
endif
let pre = substitute(matchstr(path, '^\a\a\+\ze:'), '^.', '\u&', '')
if len(pre) && exists('*' . pre . 'Real')
let path = s:shellslash({pre}Real(path))
let path = s:Slash({pre}Real(path))
endif
let root = resolve(path)
if root !=# path
@@ -215,6 +207,14 @@ function! FugitiveDetect(path) abort
endif
endfunction
function! s:Slash(path) abort
if &shell =~? 'cmd' || exists('+shellslash') && !&shellslash
return tr(a:path, '\', '/')
else
return a:path
endif
endfunction
augroup fugitive
autocmd!
@@ -246,7 +246,7 @@ augroup fugitive
autocmd BufReadCmd index{,.lock}
\ if FugitiveIsGitDir(expand('<amatch>:p:h')) |
\ let b:git_dir = s:shellslash(expand('<amatch>:p:h')) |
\ let b:git_dir = s:Slash(expand('<amatch>:p:h')) |
\ exe fugitive#BufReadStatus() |
\ elseif filereadable(expand('<amatch>')) |
\ read <amatch> |