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

@ -81,7 +81,7 @@ function! s:warn(str) abort
let v:warningmsg = a:str let v:warningmsg = a:str
endfunction endfunction
function! s:shellslash(path) abort function! s:Slash(path) abort
if s:winshell() if s:winshell()
return tr(a:path, '\', '/') return tr(a:path, '\', '/')
else else
@ -455,7 +455,7 @@ call s:add_methods('repo',['config', 'user'])
" Section: Buffer " Section: Buffer
function! s:DirCommitFile(path) abort function! s:DirCommitFile(path) abort
let vals = matchlist(s:shellslash(a:path), '\c^fugitive:\%(//\)\=\(.\{-\}\)\%(//\|::\)\(\x\{40\}\|[0-3]\)\(/.*\)\=$') let vals = matchlist(s:Slash(a:path), '\c^fugitive:\%(//\)\=\(.\{-\}\)\%(//\|::\)\(\x\{40\}\|[0-3]\)\(/.*\)\=$')
if empty(vals) if empty(vals)
return ['', '', ''] return ['', '', '']
endif endif
@ -484,8 +484,8 @@ function! fugitive#Path(url, ...) abort
if !a:0 || empty(a:url) if !a:0 || empty(a:url)
return fugitive#Real(a:url) return fugitive#Real(a:url)
endif endif
let url = s:shellslash(fnamemodify(a:url, ':p')) let url = s:Slash(fnamemodify(a:url, ':p'))
if url =~# '/$' && s:shellslash(a:url) !~# '/$' if url =~# '/$' && s:Slash(a:url) !~# '/$'
let url = url[0:-2] let url = url[0:-2]
endif endif
let dir = a:0 > 1 ? a:2 : get(b:, 'git_dir', '') let dir = a:0 > 1 ? a:2 : get(b:, 'git_dir', '')
@ -501,7 +501,7 @@ function! fugitive#Path(url, ...) abort
let file = '/' let file = '/'
endif endif
if empty(file) && a:1 =~# '^\%([.:]\=/\)\=$' if empty(file) && a:1 =~# '^\%([.:]\=/\)\=$'
return s:shellslash(fugitive#Real(a:url)) return s:Slash(fugitive#Real(a:url))
endif endif
return substitute(file, '^/', a:1, '') return substitute(file, '^/', a:1, '')
endfunction endfunction
@ -838,14 +838,14 @@ if has('win32')
for i in split(bufname,'[^:]\zs\\') for i in split(bufname,'[^:]\zs\\')
let retval = fnamemodify((retval==''?'':retval.'\').i,':.') let retval = fnamemodify((retval==''?'':retval.'\').i,':.')
endfor endfor
return s:shellslash(fnamemodify(retval,':p')) return s:Slash(fnamemodify(retval,':p'))
endfunction endfunction
else else
function! s:buffer_spec() dict abort function! s:buffer_spec() dict abort
let bufname = bufname(self['#']) let bufname = bufname(self['#'])
return s:shellslash(bufname == '' ? '' : fnamemodify(bufname,':p')) return s:Slash(bufname == '' ? '' : fnamemodify(bufname,':p'))
endfunction endfunction
endif endif
@ -951,7 +951,7 @@ function! fugitive#PathComplete(base, ...) abort
else else
let matches = s:GlobComplete(tree, s:gsub(base, '/', '*&').'*') let matches = s:GlobComplete(tree, s:gsub(base, '/', '*&').'*')
endif endif
call map(matches, 's:fnameescape(s:shellslash(matchstr(a:base, strip) . v:val))') call map(matches, 's:fnameescape(s:Slash(matchstr(a:base, strip) . v:val))')
return matches return matches
endfunction endfunction
@ -961,7 +961,7 @@ function! fugitive#Complete(base, ...) abort
if a:base =~# '^\.\=/' || a:base !~# ':' if a:base =~# '^\.\=/' || a:base !~# ':'
let results = [] let results = []
if a:base =~# '^refs/' if a:base =~# '^refs/'
let results += map(s:GlobComplete(fugitive#CommonDir(dir) . '/', a:base . '*'), 's:shellslash(v:val)') let results += map(s:GlobComplete(fugitive#CommonDir(dir) . '/', a:base . '*'), 's:Slash(v:val)')
elseif a:base !~# '^\.\=/' elseif a:base !~# '^\.\=/'
let heads = ['HEAD', 'ORIG_HEAD', 'FETCH_HEAD', 'MERGE_HEAD', 'refs/'] let heads = ['HEAD', 'ORIG_HEAD', 'FETCH_HEAD', 'MERGE_HEAD', 'refs/']
let heads += sort(split(s:TreeChomp(["rev-parse","--symbolic","--branches","--tags","--remotes"], dir),"\n")) let heads += sort(split(s:TreeChomp(["rev-parse","--symbolic","--branches","--tags","--remotes"], dir),"\n"))
@ -1025,7 +1025,7 @@ function! s:ReplaceCmd(cmd) abort
endfunction endfunction
function! fugitive#BufReadStatus() abort function! fugitive#BufReadStatus() abort
let amatch = s:shellslash(expand('%:p')) let amatch = s:Slash(expand('%:p'))
if !exists('b:fugitive_display_format') if !exists('b:fugitive_display_format')
let b:fugitive_display_format = filereadable(expand('%').'.lock') let b:fugitive_display_format = filereadable(expand('%').'.lock')
endif endif
@ -1396,7 +1396,7 @@ endfunction
function! s:DirComplete(A, L, P) abort function! s:DirComplete(A, L, P) abort
let base = s:sub(a:A,'^/','') let base = s:sub(a:A,'^/','')
let matches = split(glob(s:Tree() . '/' . s:gsub(base,'/','*&').'*/'),"\n") let matches = split(glob(s:Tree() . '/' . s:gsub(base,'/','*&').'*/'),"\n")
call map(matches,'s:shellslash(v:val[ strlen(s:Tree())+(a:A !~ "^/") : -1 ])') call map(matches,'s:Slash(v:val[ strlen(s:Tree())+(a:A !~ "^/") : -1 ])')
return matches return matches
endfunction endfunction

View File

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