From: Junio C Hamano <gitster@pobox.com>
To: Chen Linxuan via B4 Relay <devnull+me.black-desk.cn@kernel.org>
Cc: git@vger.kernel.org,
Kristoffer Haugsbakk <kristofferhaugsbakk@fastmail.com>,
Patrick Steinhardt <ps@pks.im>, Chen Linxuan <me@black-desk.cn>,
Phillip Wood <phillip.wood@dunelm.org.uk>
Subject: Re: [PATCH v5 0/2] includeIf: add "worktree" condition for matching working tree path
Date: Mon, 25 May 2026 16:31:22 +0900 [thread overview]
Message-ID: <xmqqjysseyid.fsf@gitster.g> (raw)
In-Reply-To: <20260525-includeif-worktree-v5-0-1efe525d025a@black-desk.cn> (Chen Linxuan via's message of "Mon, 25 May 2026 11:20:07 +0800")
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
next prev parent reply other threads:[~2026-05-25 7:31 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-25 3:20 [PATCH v5 0/2] includeIf: add "worktree" condition for matching working tree path Chen Linxuan via B4 Relay
2026-05-25 3:20 ` Chen Linxuan
2026-05-25 3:20 ` [PATCH v5 1/2] config: refactor include_by_gitdir() into include_by_path() Chen Linxuan via B4 Relay
2026-05-25 3:20 ` Chen Linxuan
2026-05-25 3:20 ` [PATCH v5 2/2] config: add "worktree" and "worktree/i" includeIf conditions Chen Linxuan via B4 Relay
2026-05-25 3:20 ` Chen Linxuan
2026-05-25 7:31 ` Junio C Hamano [this message]
2026-05-25 9:00 ` [PATCH v5 0/2] includeIf: add "worktree" condition for matching working tree path Chen Linxuan
2026-05-25 9:24 ` Junio C Hamano
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=xmqqjysseyid.fsf@gitster.g \
--to=gitster@pobox.com \
--cc=devnull+me.black-desk.cn@kernel.org \
--cc=git@vger.kernel.org \
--cc=kristofferhaugsbakk@fastmail.com \
--cc=me@black-desk.cn \
--cc=phillip.wood@dunelm.org.uk \
--cc=ps@pks.im \
/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.