All of lore.kernel.org
 help / color / mirror / Atom feed
From: Taylor Blau <me@ttaylorr.com>
To: Jason Karns <jason.karns@gmail.com>
Cc: git@vger.kernel.org
Subject: Re: [BUG] Suspected with double asterisk in conditional include pattern
Date: Fri, 22 Mar 2019 15:04:00 -0400	[thread overview]
Message-ID: <20190322190400.GD12155@Taylors-MacBook-Pro.local> (raw)
In-Reply-To: <CAKNmmv26G05GO7hG9bNvMsjpuUMHZRA+2f94TuG2wDNUwNhHkw@mail.gmail.com>

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

  reply	other threads:[~2019-03-22 19:04 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-14 17:30 [BUG] Suspected with double asterisk in conditional include pattern Jason Karns
2019-03-22 19:04 ` Taylor Blau [this message]
2019-03-23  3:45 ` [PATCH] config: correct '**' matching in includeIf patterns Nguyễn Thái Ngọc Duy
2019-03-24 12:56   ` Junio C Hamano
2019-03-24 13:17   ` [PATCH v2] " Nguyễn Thái Ngọc Duy
2019-03-25  2:30     ` Junio C Hamano
2019-03-25 21:40     ` Johannes Schindelin
2019-03-26  9:41     ` [PATCH v3] " Nguyễn Thái Ngọc Duy
2019-04-30 22:07       ` Jason Karns

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190322190400.GD12155@Taylors-MacBook-Pro.local \
    --to=me@ttaylorr.com \
    --cc=git@vger.kernel.org \
    --cc=jason.karns@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.