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

Re: [PATCH v5 0/2] includeIf: add "worktree" condition for matching working tree path

From
Junio C Hamano <gitster@pobox.com>
Date
May 25, 2026, 07:31 UTC
Message-ID
<xmqqjysseyid.fsf@gitster.g>
In-Reply-To
<20260525-includeif-worktree-v5-0-1efe525d025a@black-desk.cn>

Chen Linxuan via B4 Relay <devnull+me.black-desk.cn@kernel.org> writes:

> Changes in v5:
> - Fix Windows CI failure: use `**` glob pattern instead of `/` in the
>   "worktree without repository" tests, since `/` as a path pattern is
>   Unix-specific and does not match Windows paths.

Would it have worked if you used something like "[/\\].path", instead of "/.path", to cover directory delimiters for both systems?

I am not asking to make further changes. I am trying to understand what the extent of the problem was.

There are tons of [includeIf] that spells path patterns with the assumption that '/' can be used as the directory separator, like these lines taken from <master:t/t1305-config-include.sh>:

    echo "[includeIf \"gitdir:foo/\"]path=bar" >>.git/config &&
    echo "[includeIf \"gitdir:~/foo/\"]path=bar2" >>.git/config &&
    echo "[includeIf \"gitdir:**/foo/**\"]path=bar3" >>.git/config &&
    echo "[includeIf \"gitdir:./foo/.git\"]path=bar4" >>.gitconfig &&
    echo "[includeIf \"gitdir/i:FOO/\"]path=bar5" >>.git/config &&
    echo "[includeIf \"gitdir:foo/\"]path=bar6" >>.git/config &&
    [includeIf "gitdir:**/foo/**/bar/**"]
    echo "[includeIf \"gitdir:~/foo/\"]path=bar2" >>.git/config &&
    echo "[includeIf \"gitdir:./foo/.git\"]path=bar4" >home/.gitconfig &&
    echo "[includeIf \"gitdir:bar/\"]path=bar7" >>.git/config &&
    echo "[includeIf \"gitdir/i:BAR/\"]path=bar8" >>.git/config &&
    echo "[includeIf \"onbranch:foo-branch\"]path=bar9" >>.git/config &&
    echo "[includeIf \"onbranch:?oo-*/**\"]path=bar10" >>.git/config &&
    echo "[includeIf \"onbranch:foo-dir/\"]path=bar11" >>.git/config &&

and there is none, as far as I can tell, that uses a backslash as directory separator.

Shoudln't the new worktree location code normalize the pathname before doing a pattern matching so that it would allow '/'-separated path pattern to match?

FWIW, here is the diff between v4 and v5.
 t/t1305-config-include.sh | 17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)
diff --git c/t/t1305-config-include.sh w/t/t1305-config-include.sh
index 07b6fb649c..25f484eec5 100755
--- c/t/t1305-config-include.sh
+++ w/t/t1305-config-include.sh
@@ -462,6 +462,19 @@ test_expect_success SYMLINKS 'conditional include, worktree resolves symlinks' '
 	)
 '
 
+test_expect_success !CASE_INSENSITIVE_FS 'conditional include, worktree, case sensitive' '
+	git init wt-case &&
+	(
+		cd wt-case &&
+		test_commit initial &&
+		wt_path="$(pwd)" &&
+		wt_upper=$(echo "$wt_path" | tr a-z A-Z) &&
+		echo "[includeIf \"worktree:$wt_upper\"]path=case-inc" >>.git/config &&
+		echo "[test]wtcase=1" >.git/case-inc &&
+		test_must_fail git config test.wtcase
+	)
+'
+
 test_expect_success 'conditional include, worktree, icase' '
 	git init wt-icase &&
 	(
@@ -495,7 +508,7 @@ test_expect_success 'conditional include, worktree does not match in early confi
 
 test_expect_success 'conditional include, worktree without repository' '
 	test_when_finished "rm -f .gitconfig config.inc" &&
-	git config set -f .gitconfig "includeIf.worktree:/.path" config.inc &&
+	git config set -f .gitconfig "includeIf.worktree:**.path" config.inc &&
 	git config set -f config.inc foo.bar baz &&
 	git config get foo.bar &&
 	test_must_fail nongit git config get foo.bar
@@ -503,7 +516,7 @@ test_expect_success 'conditional include, worktree without repository' '
 
 test_expect_success 'conditional include, worktree without repository but explicit nonexistent Git directory' '
 	test_when_finished "rm -f .gitconfig config.inc" &&
-	git config set -f .gitconfig "includeIf.worktree:/.path" config.inc &&
+	git config set -f .gitconfig "includeIf.worktree:**.path" config.inc &&
 	git config set -f config.inc foo.bar baz &&
 	git config get foo.bar &&
 	test_must_fail nongit git --git-dir=nonexistent config get foo.bar
Previous: Chen Linxuan via B4 RelayNext: Chen Linxuan
Message 4 of 6 in “includeIf: add "worktree" condition for matching working tree path”
  1. 0/2 includeIf: add "worktree" condition for matching working tree pathChen Linxuan via B4 Relay, May 25, 2026
  2. 1/2 config: refactor include_by_gitdir() into include_by_path()Chen Linxuan via B4 Relay, May 25, 2026
  3. 2/2 config: add "worktree" and "worktree/i" includeIf conditionsChen Linxuan via B4 Relay, May 25, 2026
  4. Junio C HamanoMay 25, 2026
  5. Chen LinxuanMay 25, 2026
  6. Junio C HamanoMay 25, 2026

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.