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