From: Jason Karns <jason.karns@gmail.com>
To: "Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>
Cc: git@vger.kernel.org, gitster@pobox.com, me@ttaylorr.com,
johannes.schindelin@gmx.de
Subject: Re: [PATCH v3] config: correct '**' matching in includeIf patterns
Date: Tue, 30 Apr 2019 18:07:06 -0400 [thread overview]
Message-ID: <CAKNmmv1Y48zfUZ0TvjDVdVngrMyA1YyNacdNbw7O05_E4FHsbQ@mail.gmail.com> (raw)
In-Reply-To: <20190326094101.26294-1-pclouds@gmail.com>
On Tue, Mar 26, 2019 at 5:42 AM Nguyễn Thái Ngọc Duy <pclouds@gmail.com> wrote:
>
> 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.
>
> Reported-by: Jason Karns <jason.karns@gmail.com>
> Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
> ---
> v3 updates the test to avoid mkdir and cd, and break long lines.
>
> config.c | 2 +-
> t/t1305-config-include.sh | 13 +++++++++++++
> 2 files changed, 14 insertions(+), 1 deletion(-)
>
> diff --git a/config.c b/config.c
> index 0f0cdd8c0f..c2846df3f1 100644
> --- a/config.c
> +++ b/config.c
> @@ -242,7 +242,7 @@ static int include_by_gitdir(const struct config_options *opts,
> }
>
> ret = !wildmatch(pattern.buf + prefix, text.buf + prefix,
> - icase ? WM_CASEFOLD : 0);
> + WM_PATHNAME | (icase ? WM_CASEFOLD : 0));
>
> if (!ret && !already_tried_absolute) {
> /*
> diff --git a/t/t1305-config-include.sh b/t/t1305-config-include.sh
> index 635918505d..579a86b7f8 100755
> --- a/t/t1305-config-include.sh
> +++ b/t/t1305-config-include.sh
> @@ -229,6 +229,19 @@ test_expect_success 'conditional include, early config reading' '
> )
> '
>
> +test_expect_success 'conditional include with /**/' '
> + REPO=foo/bar/repo &&
> + git init $REPO &&
> + cat >>$REPO/.git/config <<-\EOF &&
> + [includeIf "gitdir:**/foo/**/bar/**"]
> + path=bar7
> + EOF
> + echo "[test]seven=7" >$REPO/.git/bar7 &&
> + echo 7 >expect &&
> + git -C $REPO config test.seven >actual &&
> + test_cmp expect actual
> +'
> +
> test_expect_success SYMLINKS 'conditional include, set up symlinked $HOME' '
> mkdir real-home &&
> ln -s real-home home &&
> --
> 2.21.0.479.g47ac719cd3
>
Thank you all for looking into this! (and your work on git!) It is
very much appreciated.
Jason
prev parent reply other threads:[~2019-04-30 22:07 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
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 [this message]
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
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAKNmmv1Y48zfUZ0TvjDVdVngrMyA1YyNacdNbw7O05_E4FHsbQ@mail.gmail.com \
--to=jason.karns@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=johannes.schindelin@gmx.de \
--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.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).