# HG changeset patch # User Matt Mackall # Date 2014-06-27 22:20:50 # Node ID 212955411633acbe7ace88f22565ce17d85ec8c5 # Parent 5125856a28cf96ab4b54712ab86732f06e87b34a # Parent a4b67bf1f0a5051736c14d9c13fae50fd5f5e464 merge with stable diff --git a/mercurial/match.py b/mercurial/match.py --- a/mercurial/match.py +++ b/mercurial/match.py @@ -233,6 +233,10 @@ def _globre(pat): [^/]* >>> print _globre(r'**') .* + >>> print _globre(r'**/a') + (?:.*/)?a + >>> print _globre(r'a/**/b') + a\/(?:.*/)?b >>> print _globre(r'[a*?!^][^b][!c]') [a*?!^][\^b][^c] >>> print _globre(r'{a,b}') @@ -254,7 +258,11 @@ def _globre(pat): elif c == '*': if peek() == '*': i += 1 - res += '.*' + if peek() == '/': + i += 1 + res += '(?:.*/)?' + else: + res += '.*' else: res += '[^/]*' elif c == '?': diff --git a/tests/test-hgignore.t b/tests/test-hgignore.t --- a/tests/test-hgignore.t +++ b/tests/test-hgignore.t @@ -134,3 +134,17 @@ Check patterns that match only the direc ? a.c ? a.o ? syntax + +Check recursive glob pattern matches no directories (dir/**/c.o matches dir/c.o) + + $ echo "syntax: glob" > .hgignore + $ echo "dir/**/c.o" >> .hgignore + $ touch dir/c.o + $ mkdir dir/subdir + $ touch dir/subdir/c.o + $ hg status + A dir/b.o + ? .hgignore + ? a.c + ? a.o + ? syntax