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

Re: [PATCH v2] config: correct '**' matching in includeIf patterns

From
Junio C Hamano <gitster@pobox.com>
Date
Mar 25, 2019, 02:30 UTC
Message-ID
<xmqqa7hjofc8.fsf@gitster-ct.c.googlers.com>
In-Reply-To
<20190324131755.26821-1-pclouds@gmail.com>
Nguyễn Thái Ngọc Duy  <pclouds@gmail.com> writes:
Show 15 quoted lines
> 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.
Show 12 quoted lines
> +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.

Previous: Nguyễn Thái Ngọc DuyNext: Johannes Schindelin
Message 6 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.