Re: [BUG] Suspected with double asterisk in conditional include pattern
- From
Taylor Blau <me@ttaylorr.com>
- Date
- Mar 22, 2019, 19:04 UTC
- Message-ID
- <20190322190400.GD12155@Taylors-MacBook-Pro.local>
- In-Reply-To
- <CAKNmmv26G05GO7hG9bNvMsjpuUMHZRA+2f94TuG2wDNUwNhHkw@mail.gmail.com>
Hi Jason,
On Thu, Mar 14, 2019 at 01:30:43PM -0400, Jason Karns wrote:
Show 23 quoted lines
> 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