Hi Jason, On Thu, Mar 14, 2019 at 01:30:43PM -0400, Jason Karns wrote: > Hello, > > I believe I've encountered a bug regarding the use of double asterisk > ( /**/ ) within includeIf patterns. > > git-config man pages state that > > **/ and /**, that can match multiple path components > > They then refer to the gitignore man pages which further define > supported wildcard patterns: > > A slash followed by two consecutive asterisks then a slash matches > zero or more directories. > For example, "a/**/b" matches "a/b", "a/x/b", "a/x/y/b" and so on. > > My understanding of these docs are that the pattern > `/usr/local/**/Homebrew/` ought to match > both`/usr/local/cache/Homebrew/foo` and `/usr/local/Homebrew/foo`. > > However, given the following conditional include rule: > > [includeIf "gitdir:/usr/local/**/Homebrew/"] For what it's worth, Git LFS's implementation of the wildmatch algorithm [1] exhibits the same behavior (i.e., that it does _not_ match those double stars in the middle of the pathspec). Here are the tests I added to double check: { Pattern: `/usr/local/**/Homebrew/`, Subject: `/usr/local/cache/Homebrew/foo`, Match: false, }, { Pattern: `/usr/local/**/Homebrew/`, Subject: `/usr/local/Homebrew/foo`, Match: false, }, And they passed, indicating that neither of the above subjects are a match for the pattern '/usr/local/**/Homebrew'. I was suspicious that changing the pattern to '/usr/local/**/Homebrew/*' might have caused it to match, but it did not. But this isn't really telling us anything that we don't know. What's interesting is that '/usr/local/**/Homebrew' _does_ match '/usr/local/Homebrew' and '/usr/local/cache/Homebrew'. I think that this is consistent with [2]: A slash followed by two consecutive asterisks then a slash matches zero or more directories. For example, "a/**/b" matches "a/b", "a/x/b", "a/x/y/b" and so on. So I think that there _is_ a bug here, but not the one you suggested. Rather, I think that the bug is that with the _trailing_ wildcard, the pathspec doesn't accept '/usr/local/cache/Homebrew/a'. Thanks, Taylor [1]: https://github.com/git-lfs/wildmatch [2]: https://git-scm.com/docs/gitignore