Accept ./ paths as relative to cwd
This commit is contained in:
parent
45c21fc384
commit
7b0aa58090
@ -510,11 +510,11 @@ function! fugitive#Route(object, ...) abort
|
|||||||
return s:PlatformSlash((len(owner) ? owner : prefix) . strpart(a:object, len(prefix)))
|
return s:PlatformSlash((len(owner) ? owner : prefix) . strpart(a:object, len(prefix)))
|
||||||
elseif s:Slash(a:object) =~# '^/\|^\%(\a\a\+:\).*\%(//\|::\)' || (has('win32') ? '^\a:/' : '')
|
elseif s:Slash(a:object) =~# '^/\|^\%(\a\a\+:\).*\%(//\|::\)' || (has('win32') ? '^\a:/' : '')
|
||||||
return s:PlatformSlash(a:object)
|
return s:PlatformSlash(a:object)
|
||||||
|
elseif s:Slash(a:object) =~# '^\.\.\=\%(/\|$\)'
|
||||||
|
return s:PlatformSlash(simplify(getcwd() . '/' . a:object))
|
||||||
endif
|
endif
|
||||||
let dir = a:0 ? a:1 : get(b:, 'git_dir', '')
|
let dir = a:0 ? a:1 : get(b:, 'git_dir', '')
|
||||||
if empty(dir) && a:object =~# '^\.\.\=\%(/\|$\)'
|
if empty(dir)
|
||||||
return s:PlatformSlash(simplify(getcwd() . '/' . a:object[1:-1]))
|
|
||||||
elseif empty(dir)
|
|
||||||
let file = matchstr(a:object, '^\%(:\d:\|[^:]*:\)\zs.*', '', '')
|
let file = matchstr(a:object, '^\%(:\d:\|[^:]*:\)\zs.*', '', '')
|
||||||
let dir = FugitiveExtractGitDir(file)
|
let dir = FugitiveExtractGitDir(file)
|
||||||
if empty(dir)
|
if empty(dir)
|
||||||
@ -1079,9 +1079,9 @@ endfunction
|
|||||||
|
|
||||||
function! fugitive#PathComplete(base, ...) abort
|
function! fugitive#PathComplete(base, ...) abort
|
||||||
let dir = a:0 == 1 ? a:1 : get(b:, 'git_dir', '')
|
let dir = a:0 == 1 ? a:1 : get(b:, 'git_dir', '')
|
||||||
let tree = FugitiveTreeForGitDir(dir) . '/'
|
let tree = s:Tree(dir) . '/'
|
||||||
let strip = '^\%(:/:\=\|:(top)\|:(top,literal)\|:(literal,top)\|:(literal)\)\%(\./\)\='
|
let strip = '^\%(:/:\=\|:(top)\|:(top,literal)\|:(literal,top)\|:(literal)\)'
|
||||||
let base = substitute((a:base =~# '^/' ? '.' : '') . a:base, strip, '', '')
|
let base = substitute(a:base, strip, '', '')
|
||||||
if base =~# '^\.git/'
|
if base =~# '^\.git/'
|
||||||
let pattern = s:gsub(base[5:-1], '/', '*&').'*'
|
let pattern = s:gsub(base[5:-1], '/', '*&').'*'
|
||||||
let matches = s:GlobComplete(dir . '/', pattern)
|
let matches = s:GlobComplete(dir . '/', pattern)
|
||||||
@ -1093,14 +1093,13 @@ function! fugitive#PathComplete(base, ...) abort
|
|||||||
call map(matches, "'.git/' . v:val")
|
call map(matches, "'.git/' . v:val")
|
||||||
elseif base =~# '^\~/'
|
elseif base =~# '^\~/'
|
||||||
let matches = map(s:GlobComplete(expand('~/'), base[2:-1] . '*'), '"~/" . v:val')
|
let matches = map(s:GlobComplete(expand('~/'), base[2:-1] . '*'), '"~/" . v:val')
|
||||||
|
elseif a:base =~# '^/\|^\a\+:\|^\.\.\=/\|^:(literal)'
|
||||||
|
let matches = s:GlobComplete('', base . '*')
|
||||||
elseif len(tree) > 1
|
elseif len(tree) > 1
|
||||||
let matches = s:GlobComplete(tree, s:gsub(base, '/', '*&').'*')
|
let matches = s:GlobComplete(tree, s:gsub(base, '/', '*&').'*')
|
||||||
else
|
else
|
||||||
let matches = []
|
let matches = []
|
||||||
endif
|
endif
|
||||||
if empty(matches) && a:base =~# '^/\|^\a\+:'
|
|
||||||
let matches = s:GlobComplete('', a:base . '*')
|
|
||||||
endif
|
|
||||||
call map(matches, 's:fnameescape(s:Slash(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
|
||||||
@ -1573,7 +1572,7 @@ endfunction
|
|||||||
|
|
||||||
function! s:DirArg(path) abort
|
function! s:DirArg(path) abort
|
||||||
let path = substitute(a:path, '^:/:\=\|^:(\%(top\|top,literal\|literal,top\|literal\))', '', '')
|
let path = substitute(a:path, '^:/:\=\|^:(\%(top\|top,literal\|literal,top\|literal\))', '', '')
|
||||||
if path =~# '^/\|^\a\+:'
|
if path =~# '^/\|^\a\+:\|^\.\.\=\%(/\|$\)'
|
||||||
return path
|
return path
|
||||||
else
|
else
|
||||||
return (empty(s:Tree()) ? b:git_dir : s:Tree()) . '/' . path
|
return (empty(s:Tree()) ? b:git_dir : s:Tree()) . '/' . path
|
||||||
@ -2239,9 +2238,9 @@ function! s:EditParse(args) abort
|
|||||||
elseif empty(expand('%'))
|
elseif empty(expand('%'))
|
||||||
let file = ':'
|
let file = ':'
|
||||||
elseif empty(s:DirCommitFile(@%)[1]) && s:Relative('./') !~# '^\./\.git\>'
|
elseif empty(s:DirCommitFile(@%)[1]) && s:Relative('./') !~# '^\./\.git\>'
|
||||||
let file = s:Relative(':0:')
|
let file = ':0:%'
|
||||||
else
|
else
|
||||||
let file = s:Relative('./')
|
let file = '%'
|
||||||
endif
|
endif
|
||||||
return [s:Expand(file), join(pre)]
|
return [s:Expand(file), join(pre)]
|
||||||
endfunction
|
endfunction
|
||||||
@ -2760,18 +2759,22 @@ endfunction
|
|||||||
" Section: :Gmove, :Gremove
|
" Section: :Gmove, :Gremove
|
||||||
|
|
||||||
function! s:Move(force, rename, destination) abort
|
function! s:Move(force, rename, destination) abort
|
||||||
if a:destination =~# '^\./.'
|
if a:destination =~# '^\.\.\=\%(/\|$\)'
|
||||||
let destination = a:destination[2:-1]
|
let destination = simplify(getcwd() . '/' . a:destination)
|
||||||
elseif a:destination =~# '^:/:\='
|
elseif a:destination =~# '^\a\+:\|^/'
|
||||||
let destination = substitute(a:destination, '^:/:\=', '', '')
|
|
||||||
elseif a:destination =~# '^:(\%(top\|top,literal\|literal,top\|literal\))'
|
|
||||||
let destination = matchstr(a:destination, ')\zs.*')
|
|
||||||
elseif a:rename && a:destination !~# '^\a\+:\|^/'
|
|
||||||
let destination = fnamemodify(s:Relative(''), ':h') . '/' . a:destination
|
|
||||||
else
|
|
||||||
let destination = a:destination
|
let destination = a:destination
|
||||||
|
elseif a:destination =~# '^:/:\='
|
||||||
|
let destination = s:Tree() . substitute(a:destination, '^:/:\=', '', '')
|
||||||
|
elseif a:destination =~# '^:(\%(top\|top,literal\|literal,top\))'
|
||||||
|
let destination = s:Tree() . matchstr(a:destination, ')\zs.*')
|
||||||
|
elseif a:destination =~# '^:(literal)'
|
||||||
|
let destination = simplify(getcwd() . '/' . matchstr(a:destination, ')\zs.*'))
|
||||||
|
elseif a:rename
|
||||||
|
let destination = expand('%:p:s?[\/]$??:h') . '/' . a:destination
|
||||||
|
else
|
||||||
|
let destination = s:Tree() . '/' . a:destination
|
||||||
endif
|
endif
|
||||||
let destination = s:Tree() . '/' . destination
|
let destination = s:Slash(destination)
|
||||||
if isdirectory(@%)
|
if isdirectory(@%)
|
||||||
setlocal noswapfile
|
setlocal noswapfile
|
||||||
endif
|
endif
|
||||||
|
@ -323,7 +323,7 @@ refs/heads/x .git/refs/heads/x
|
|||||||
@ The commit referenced by @ aka HEAD
|
@ The commit referenced by @ aka HEAD
|
||||||
master^ The parent of the commit referenced by master
|
master^ The parent of the commit referenced by master
|
||||||
master: The tree referenced by master
|
master: The tree referenced by master
|
||||||
./master The file named master in the work tree
|
./master The file named master in the working directory
|
||||||
Makefile The file named Makefile in the work tree
|
Makefile The file named Makefile in the work tree
|
||||||
@^:Makefile The file named Makefile in the parent of HEAD
|
@^:Makefile The file named Makefile in the parent of HEAD
|
||||||
:Makefile The file named Makefile in the index (writable)
|
:Makefile The file named Makefile in the index (writable)
|
||||||
|
Loading…
Reference in New Issue
Block a user