t5503: avoid discovering a bare repository

The test case "fetch specific OID with tag following" creates a bare
repository and wants to operate on it by changing the working directory
and relying on Git's implicit discovery of the bare repository.

Once the `safe.bareRepository` default is changed, this is no longer
an option.

So let's adjust the commands to specify the bare repository explicitly,
via `--git-dir`, and avoid changing the working directory. As a bonus,
the result is arguably more readable than the original code.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Johannes Schindelin
2026-04-02 14:33:15 +00:00
committed by Junio C Hamano
parent f71488534d
commit 58c5358a63

View File

@@ -168,16 +168,13 @@ test_expect_success 'new clone fetch main and tags' '
test_expect_success 'fetch specific OID with tag following' '
git init --bare clone3.git &&
(
cd clone3.git &&
git remote add origin .. &&
git fetch origin $B:refs/heads/main &&
git --git-dir=clone3.git remote add origin "$PWD" &&
git --git-dir=clone3.git fetch origin $B:refs/heads/main &&
git -C .. for-each-ref >expect &&
git for-each-ref >actual &&
git for-each-ref >expect &&
git --git-dir=clone3.git for-each-ref >actual &&
test_cmp expect actual
)
test_cmp expect actual
'
test_done