From 2ca0765dc4ce1520c38c796990f9bd99a51cb351 Mon Sep 17 00:00:00 2001 From: Tim Pope Date: Fri, 10 Aug 2018 03:14:47 -0400 Subject: [PATCH] Ignore dot files when globbing --- autoload/fugitive.vim | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) 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')