Skip to content

Commit d8e4e1b

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 755be63 commit d8e4e1b

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
@@ -258,7 +258,7 @@ test_http_push_nonff () {
258258

259259
test_expect_success 'non-fast-forward push fails' '
260260
cd "$REMOTE_REPO" &&
261-
HEAD=$(git rev-parse --verify HEAD) &&
261+
HEAD=$(git --git-dir=. rev-parse --verify HEAD) &&
262262
263263
cd "$LOCAL_REPO" &&
264264
git checkout $BRANCH &&
@@ -269,7 +269,7 @@ test_http_push_nonff () {
269269
(
270270
cd "$REMOTE_REPO" &&
271271
echo "$HEAD" >expect &&
272-
git rev-parse --verify HEAD >actual &&
272+
git --git-dir=. rev-parse --verify HEAD >actual &&
273273
test_cmp expect actual
274274
)
275275
'
@@ -283,18 +283,16 @@ test_http_push_nonff () {
283283
'
284284

285285
test_expect_${EXPECT_CAS_RESULT} 'force with lease aka cas' '
286-
HEAD=$( cd "$REMOTE_REPO" && git rev-parse --verify HEAD ) &&
286+
HEAD=$(git --git-dir="$REMOTE_REPO" rev-parse --verify HEAD) &&
287287
test_when_finished '\''
288-
(cd "$REMOTE_REPO" && git update-ref HEAD "$HEAD")
288+
git --git-dir="$REMOTE_REPO" update-ref HEAD "$HEAD"
289289
'\'' &&
290290
(
291291
cd "$LOCAL_REPO" &&
292292
git push -v --force-with-lease=$BRANCH:$HEAD origin
293293
) &&
294294
git rev-parse --verify "$BRANCH" >expect &&
295-
(
296-
cd "$REMOTE_REPO" && git rev-parse --verify HEAD
297-
) >actual &&
295+
git --git-dir="$REMOTE_REPO" rev-parse --verify HEAD >actual &&
298296
test_cmp expect actual
299297
'
300298
}

0 commit comments

Comments
 (0)