From c85980cd93eb554b45a5d0da7883c9dcaae37749 Mon Sep 17 00:00:00 2001 From: Tim Pope Date: Mon, 30 Jul 2018 01:35:11 -0400 Subject: [PATCH] Rename s:shellslash() to s:Slash() --- autoload/fugitive.vim | 22 +++++++++++----------- plugin/fugitive.vim | 28 ++++++++++++++-------------- 2 files changed, 25 insertions(+), 25 deletions(-) diff --git a/autoload/fugitive.vim b/autoload/fugitive.vim index 7f10078..20722af 100644 --- a/autoload/fugitive.vim +++ b/autoload/fugitive.vim @@ -81,7 +81,7 @@ function! s:warn(str) abort let v:warningmsg = a:str endfunction -function! s:shellslash(path) abort +function! s:Slash(path) abort if s:winshell() return tr(a:path, '\', '/') else @@ -455,7 +455,7 @@ call s:add_methods('repo',['config', 'user']) " Section: Buffer 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) return ['', '', ''] endif @@ -484,8 +484,8 @@ function! fugitive#Path(url, ...) abort if !a:0 || empty(a:url) return fugitive#Real(a:url) endif - let url = s:shellslash(fnamemodify(a:url, ':p')) - if url =~# '/$' && s:shellslash(a:url) !~# '/$' + let url = s:Slash(fnamemodify(a:url, ':p')) + if url =~# '/$' && s:Slash(a:url) !~# '/$' let url = url[0:-2] endif let dir = a:0 > 1 ? a:2 : get(b:, 'git_dir', '') @@ -501,7 +501,7 @@ function! fugitive#Path(url, ...) abort let file = '/' endif if empty(file) && a:1 =~# '^\%([.:]\=/\)\=$' - return s:shellslash(fugitive#Real(a:url)) + return s:Slash(fugitive#Real(a:url)) endif return substitute(file, '^/', a:1, '') endfunction @@ -838,14 +838,14 @@ if has('win32') for i in split(bufname,'[^:]\zs\\') let retval = fnamemodify((retval==''?'':retval.'\').i,':.') endfor - return s:shellslash(fnamemodify(retval,':p')) + return s:Slash(fnamemodify(retval,':p')) endfunction else function! s:buffer_spec() dict abort let bufname = bufname(self['#']) - return s:shellslash(bufname == '' ? '' : fnamemodify(bufname,':p')) + return s:Slash(bufname == '' ? '' : fnamemodify(bufname,':p')) endfunction endif @@ -951,7 +951,7 @@ function! fugitive#PathComplete(base, ...) abort else let matches = s:GlobComplete(tree, s:gsub(base, '/', '*&').'*') 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 endfunction @@ -961,7 +961,7 @@ function! fugitive#Complete(base, ...) abort if a:base =~# '^\.\=/' || a:base !~# ':' let results = [] 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 !~# '^\.\=/' let heads = ['HEAD', 'ORIG_HEAD', 'FETCH_HEAD', 'MERGE_HEAD', 'refs/'] let heads += sort(split(s:TreeChomp(["rev-parse","--symbolic","--branches","--tags","--remotes"], dir),"\n")) @@ -1025,7 +1025,7 @@ function! s:ReplaceCmd(cmd) abort endfunction function! fugitive#BufReadStatus() abort - let amatch = s:shellslash(expand('%:p')) + let amatch = s:Slash(expand('%:p')) if !exists('b:fugitive_display_format') let b:fugitive_display_format = filereadable(expand('%').'.lock') endif @@ -1396,7 +1396,7 @@ endfunction function! s:DirComplete(A, L, P) abort let base = s:sub(a:A,'^/','') 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 endfunction diff --git a/plugin/fugitive.vim b/plugin/fugitive.vim index d581674..1b18393 100644 --- a/plugin/fugitive.vim +++ b/plugin/fugitive.vim @@ -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(':p:h')) | - \ let b:git_dir = s:shellslash(expand(':p:h')) | + \ let b:git_dir = s:Slash(expand(':p:h')) | \ exe fugitive#BufReadStatus() | \ elseif filereadable(expand('')) | \ read | -- 2.11.4.GIT