git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

Previous: Jason KarnsNext: Nguyễn Thái Ngọc Duy
Message 2 of 9 in “[BUG] Suspected with double asterisk in conditional include pattern”
  1. Jason KarnsMar 14, 2019
  2. Taylor BlauMar 22, 2019
  3. config: correct '**' matching in includeIf patternsNguyễn Thái Ngọc Duy, Mar 23, 2019
  4. Junio C HamanoMar 24, 2019
  5. config: correct '**' matching in includeIf patternsNguyễn Thái Ngọc Duy, Mar 24, 2019
  6. Junio C HamanoMar 25, 2019
  7. Johannes SchindelinMar 25, 2019
  8. config: correct '**' matching in includeIf patternsNguyễn Thái Ngọc Duy, Mar 26, 2019
  9. Jason KarnsApr 30, 2019

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.