Skip to content

Commit 70bd3e3

Browse files
committed
t2400: explicitly specify bare repo for git worktree add
To prepare for `safe.bareRepository` defaulting to `explicit` (see 8d1a744), specify the gitdir specifically in bare-repo `git worktree add` invocations via `--git-dir=.` so Git does not rely on implicit bare repository discovery. While at it, also avoid unnecessary subshells and `cd`ing. This simplifies the logic in a rather pleasant way. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
1 parent f3d66fa commit 70bd3e3

File tree

1 file changed

+7
-14
lines changed

1 file changed

+7
-14
lines changed

t/t2400-worktree-add.sh

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -171,11 +171,8 @@ test_expect_success 'not die on re-checking out current branch' '
171171
'
172172

173173
test_expect_success '"add" from a bare repo' '
174-
(
175-
git clone --bare . bare &&
176-
cd bare &&
177-
git worktree add -b bare-main ../there2 main
178-
)
174+
git clone --bare . bare &&
175+
git -C bare --git-dir=. worktree add -b bare-main ../there2 main
179176
'
180177

181178
test_expect_success 'checkout from a bare repo without "add"' '
@@ -186,15 +183,11 @@ test_expect_success 'checkout from a bare repo without "add"' '
186183
'
187184

188185
test_expect_success '"add" default branch of a bare repo' '
189-
(
190-
git clone --bare . bare2 &&
191-
cd bare2 &&
192-
git worktree add ../there3 main &&
193-
cd ../there3 &&
194-
# Simple check that a Git command does not
195-
# immediately fail with the current setup
196-
git status
197-
) &&
186+
git clone --bare . bare2 &&
187+
git -C bare2 --git-dir=. worktree add ../there3 main &&
188+
# Simple check that a Git command does not
189+
# immediately fail with the current setup
190+
git status &&
198191
cat >expect <<-EOF &&
199192
init.t
200193
EOF

0 commit comments

Comments
 (0)