From: randall.becker@nexbridge.ca
To: git@vger.kernel.org
Cc: "Randall S. Becker" <rsbecker@nexbridge.com>
Subject: [Patch 3/3] t1305: add tests for includeIf:worktree.
Date: Mon, 12 Jul 2021 18:31:39 -0400 [thread overview]
Message-ID: <20210712223139.24409-4-randall.becker@nexbridge.ca> (raw)
In-Reply-To: <20210712223139.24409-1-randall.becker@nexbridge.ca>
From: "Randall S. Becker" <rsbecker@nexbridge.com>
The tests are a subset of those for gitdir:, taking into account that
the worktree: form does not support the trailing / at this time in
pattern matches. Some resets of the .git/config file are done to restrict
the set of includeIf paths being evaluated that conflict with prior
subtests.
Signed-off-by: Randall S. Becker <rsbecker@nexbridge.com>
---
t/t1305-config-include.sh | 81 +++++++++++++++++++++++++++++++++++++++
1 file changed, 81 insertions(+)
diff --git a/t/t1305-config-include.sh b/t/t1305-config-include.sh
index ccbb116c01..fe1ad106c3 100755
--- a/t/t1305-config-include.sh
+++ b/t/t1305-config-include.sh
@@ -309,6 +309,69 @@ test_expect_success SYMLINKS 'conditional include, gitdir matching symlink, icas
)
'
+test_expect_success 'conditional worktree include, unanchored' '
+ (
+ cd foo &&
+ # Must add a commit for worktree add
+ git commit --allow-empty --allow-empty-message &&
+ sed -i "/includeIf/,\$d" .git/config &&
+ git worktree add ../foo.wt &&
+ echo "[includeIf \"worktree:foo.wt\"]path=bar" >>.git/config &&
+ echo "[test]one=1" >.git/bar &&
+ cd ../foo.wt &&
+ echo 1 >expect &&
+ git config test.one >actual &&
+ test_cmp expect actual
+ )
+'
+
+test_expect_success 'conditional worktree include, $HOME expansion' '
+ (
+ cd foo &&
+ echo "[includeIf \"worktree:~/foo.wt\"]path=bar2" >>.git/config &&
+ echo "[test]two=2" >.git/bar2 &&
+ cd ../foo.wt &&
+ echo 2 >expect &&
+ git config test.two >actual &&
+ test_cmp expect actual
+ )
+'
+
+test_expect_success 'conditional worktree include, full pattern' '
+ (
+ cd foo &&
+ echo "[includeIf \"worktree:**/foo.wt\"]path=bar3" >>.git/config &&
+ echo "[test]three=3" >.git/bar3 &&
+ cd ../foo.wt &&
+ echo 3 >expect &&
+ git config test.three >actual &&
+ test_cmp expect actual
+ )
+'
+
+test_expect_success 'conditional worktree include, relative path' '
+ echo "[includeIf \"worktree:./foo.wt\"]path=bar4" >>.gitconfig &&
+ echo "[test]four=4" >bar4 &&
+ (
+ cd foo.wt &&
+ echo 4 >expect &&
+ git config test.four >actual &&
+ test_cmp expect actual
+ )
+'
+
+test_expect_success 'conditional worktree include, both unanchored, icase' '
+ (
+ cd foo &&
+ echo "[includeIf \"worktree/i:FOO.WT\"]path=bar5" >>.git/config &&
+ echo "[test]five=5" >.git/bar5 &&
+ cd ../foo.wt &&
+ echo 5 >expect &&
+ git config test.five >actual &&
+ test_cmp expect actual
+ )
+'
+
test_expect_success 'conditional include, onbranch' '
echo "[includeIf \"onbranch:foo-branch\"]path=bar9" >>.git/config &&
echo "[test]nine=9" >.git/bar9 &&
@@ -348,6 +411,24 @@ test_expect_success 'conditional include, onbranch, implicit /** for /' '
test_cmp expect actual
'
+test_expect_success 'conditional worktree include, onbranch' '
+ (
+ cd foo &&
+ sed -i "/includeIf/,\$d" .git/config &&
+ echo "[includeIf \"onbranch:foo.wt2\"]path=bar12" >>.git/config &&
+ echo "[test]twelve=12" >.git/bar12
+ ) &&
+ (
+ cd foo.wt &&
+ git checkout -b main &&
+ test_must_fail git config test.twelve &&
+ git checkout -b foo.wt2 &&
+ echo 12 >expect &&
+ git config test.twelve >actual &&
+ test_cmp expect actual
+ )
+'
+
test_expect_success 'include cycles are detected' '
git init --bare cycle &&
git -C cycle config include.path cycle &&
--
2.32.0
prev parent reply other threads:[~2021-07-12 22:32 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-07-12 22:31 [Patch 0/3] includeIf series for worktrees randall.becker
2021-07-12 22:31 ` [Patch 1/3] config.c: add conditional include based on worktree randall.becker
2021-07-13 13:03 ` Johannes Schindelin
2021-07-12 22:31 ` [Patch 2/3] Documentation/config.txt: add worktree includeIf conditionals randall.becker
2021-07-14 1:04 ` Junio C Hamano
2021-07-14 13:46 ` Randall S. Becker
2021-07-14 17:10 ` Junio C Hamano
2021-07-14 17:30 ` Randall S. Becker
2021-07-12 22:31 ` randall.becker [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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210712223139.24409-4-randall.becker@nexbridge.ca \
--to=randall.becker@nexbridge.ca \
--cc=git@vger.kernel.org \
--cc=rsbecker@nexbridge.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.
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 NNTP newsgroup(s).