Skip to content

Commit c8789bd

Browse files
committed
t5540/t5541: avoid accessing a bare repository via -C <dir>
In the `test_http_push_nonff` function both of these test scripts call, there were two Git invocations that assume that bare repositories will always be discovered when the current working directory is inside one. This is unlikely to be true forever because at some stage, the `safe.bareRepository` config is prone to be modified to be safe by default. So let's be safe and specify the bare repository explicitly. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
1 parent 2f1e745 commit c8789bd

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

t/lib-httpd.sh

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ test_http_push_nonff () {
259259

260260
test_expect_success 'non-fast-forward push fails' '
261261
cd "$REMOTE_REPO" &&
262-
HEAD=$(git rev-parse --verify HEAD) &&
262+
HEAD=$(git --git-dir=. rev-parse --verify HEAD) &&
263263
264264
cd "$LOCAL_REPO" &&
265265
git checkout $BRANCH &&
@@ -270,7 +270,7 @@ test_http_push_nonff () {
270270
(
271271
cd "$REMOTE_REPO" &&
272272
echo "$HEAD" >expect &&
273-
git rev-parse --verify HEAD >actual &&
273+
git --git-dir=. rev-parse --verify HEAD >actual &&
274274
test_cmp expect actual
275275
)
276276
'
@@ -284,18 +284,16 @@ test_http_push_nonff () {
284284
'
285285

286286
test_expect_${EXPECT_CAS_RESULT} 'force with lease aka cas' '
287-
HEAD=$( cd "$REMOTE_REPO" && git rev-parse --verify HEAD ) &&
287+
HEAD=$(git --git-dir="$REMOTE_REPO" rev-parse --verify HEAD) &&
288288
test_when_finished '\''
289-
(cd "$REMOTE_REPO" && git update-ref HEAD "$HEAD")
289+
git --git-dir="$REMOTE_REPO" update-ref HEAD "$HEAD"
290290
'\'' &&
291291
(
292292
cd "$LOCAL_REPO" &&
293293
git push -v --force-with-lease=$BRANCH:$HEAD origin
294294
) &&
295295
git rev-parse --verify "$BRANCH" >expect &&
296-
(
297-
cd "$REMOTE_REPO" && git rev-parse --verify HEAD
298-
) >actual &&
296+
git --git-dir="$REMOTE_REPO" rev-parse --verify HEAD >actual &&
299297
test_cmp expect actual
300298
'
301299
}

0 commit comments

Comments
 (0)