All of lore.kernel.org
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: "Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>
Cc: git@vger.kernel.org, jason.karns@gmail.com, me@ttaylorr.com
Subject: Re: [PATCH v2] config: correct '**' matching in includeIf patterns
Date: Mon, 25 Mar 2019 11:30:47 +0900	[thread overview]
Message-ID: <xmqqa7hjofc8.fsf@gitster-ct.c.googlers.com> (raw)
In-Reply-To: <20190324131755.26821-1-pclouds@gmail.com> (=?utf-8?B?Ik5n?= =?utf-8?B?dXnhu4VuIFRow6FpIE5n4buNYw==?= Duy"'s message of "Sun, 24 Mar 2019 20:17:55 +0700")

Nguyễn Thái Ngọc Duy  <pclouds@gmail.com> writes:

> The current wildmatch() call for includeIf's gitdir pattern does not
> pass the WM_PATHNAME flag. Without this flag, '*' is treated _almost_
> the same as '**' (because '*' also matches slashes) with one exception:
>
> '/**/' can match a single slash. The pattern 'foo/**/bar' matches
> 'foo/bar'.
>
> But '/*/', which is essentially what wildmatch engine sees without
> WM_PATHNAME, has to match two slashes (and '*' matches nothing). Which
> means 'foo/*/bar' cannot match 'foo/bar'. It can only match 'foo//bar'.
>
> The result of this is the current wildmatch() call works most of the
> time until the user depends on '/**/' matching no path component. And
> also '*' matches slashes while it should not, but people probably
> haven't noticed this yet. The fix is straightforward.

> +test_expect_success 'conditional include with /**/' '
> +	mkdir foo/bar &&
> +	git init foo/bar/repo &&
> +	(
> +		cd foo/bar/repo &&
> +		echo "[includeIf \"gitdir:**/foo/**/bar/**\"]path=bar7" >>.git/config &&
> +		echo "[test]seven=7" >.git/bar7 &&
> +		echo 7 >expect &&
> +		git config test.seven >actual &&
> +		test_cmp expect actual
> +	)
> +'

That's cute ;-)

Thanks for quickly working on the fix with an incredibly short
turnaround time since the initial report.

P.S. I expect to be offline for most of the week (packing, moving
and unpacking.  Even though the places packing and unpacking happens
are within 1 kilometer radius, that does not make it less hassle
X-<).  See you guys next month.

  reply	other threads:[~2019-03-25  2:30 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
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 [this message]
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=xmqqa7hjofc8.fsf@gitster-ct.c.googlers.com \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=jason.karns@gmail.com \
    --cc=me@ttaylorr.com \
    --cc=pclouds@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.