diff --git a/autoload/fugitive.vim b/autoload/fugitive.vim index 880ef23..08292b1 100644 --- a/autoload/fugitive.vim +++ b/autoload/fugitive.vim @@ -821,12 +821,19 @@ function! fugitive#writefile(lines, url, ...) abort return call('writefile', [a:lines, a:url] + a:000) endfunction -let s:globsubs = {'*': '[^/]*', '**': '.*', '**/': '\%(.*/\)\=', '?': '[^/]'} +let s:globsubs = { + \ '/**/': '/\%([^./][^/]*/\)*', + \ '/**': '/\%([^./][^/]\+/\)*[^./][^/]*', + \ '**/': '[^/]*\%(/[^./][^/]*\)*', + \ '**': '.*', + \ '/*': '/[^/.][^/]*', + \ '*': '[^/]*', + \ '?': '[^/]'} function! fugitive#glob(url, ...) abort let [dirglob, commit, glob] = s:DirCommitFile(a:url) let append = matchstr(glob, '/*$') let glob = substitute(glob, '/*$', '', '') - let pattern = '^' . substitute(glob[1:-1], '\*\*/\=\|[.?*\^$]', '\=get(s:globsubs, submatch(0), "\\" . submatch(0))', 'g') . '$' + let pattern = '^' . substitute(glob, '/\=\*\*/\=\|/\=\*\|[.?\^$]', '\=get(s:globsubs, submatch(0), "\\" . submatch(0))', 'g')[1:-1] . '$' let results = [] for dir in dirglob =~# '[*?]' ? split(glob(dirglob), "\n") : [dirglob] if empty(dir) || !get(g:, 'fugitive_file_api', 1) || !filereadable(dir . '/HEAD')