Skip to content

Commit 20272ee

Browse files
peffgitster
authored andcommitted
t5512: add v2 support for "ls-remote --symref" test
Commit b2f73b7 (t5512: compensate for v0 only sending HEAD symrefs, 2019-02-25) configured this test to always run with protocol v0, since the output is different for v2. But that means we are not getting any test coverage of the feature with v2 at all. We could obviously switch to using and expecting v2, but then that leaves v0 behind (and while we don't use it by default, it's still important for testing interoperability with older servers). Likewise, we could switch the expected output based on $GIT_TEST_PROTOCOL_VERSION, but hardly anybody runs the tests for v0 these days. Instead, let's explicitly run it for both protocol versions to make sure they're well behaved. This matches other similar tests added later in 6a139cd (ls-remote: pass heads/tags prefixes to transport, 2018-10-31), etc. Signed-off-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 13e67aa commit 20272ee

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

t/t5512-ls-remote.sh

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -244,22 +244,25 @@ test_expect_success 'protocol v2 supports hiderefs' '
244244

245245
test_expect_success 'ls-remote --symref' '
246246
git fetch origin &&
247-
echo "ref: refs/heads/main HEAD" >expect &&
247+
echo "ref: refs/heads/main HEAD" >expect.v2 &&
248248
generate_references \
249249
HEAD \
250-
refs/heads/main >>expect &&
250+
refs/heads/main >>expect.v2 &&
251+
echo "ref: refs/remotes/origin/main refs/remotes/origin/HEAD" >>expect.v2 &&
251252
oid=$(git rev-parse HEAD) &&
252-
echo "$oid refs/remotes/origin/HEAD" >>expect &&
253+
echo "$oid refs/remotes/origin/HEAD" >>expect.v2 &&
253254
generate_references \
254255
refs/remotes/origin/main \
255256
refs/tags/mark \
256257
refs/tags/mark1.1 \
257258
refs/tags/mark1.10 \
258-
refs/tags/mark1.2 >>expect &&
259-
# Protocol v2 supports sending symrefs for refs other than HEAD, so use
260-
# protocol v0 here.
261-
GIT_TEST_PROTOCOL_VERSION=0 git ls-remote --symref >actual &&
262-
test_cmp expect actual
259+
refs/tags/mark1.2 >>expect.v2 &&
260+
# v0 does not show non-HEAD symrefs
261+
grep -v "ref: refs/remotes" <expect.v2 >expect.v0 &&
262+
git -c protocol.version=0 ls-remote --symref >actual.v0 &&
263+
test_cmp expect.v0 actual.v0 &&
264+
git -c protocol.version=2 ls-remote --symref >actual.v2 &&
265+
test_cmp expect.v2 actual.v2
263266
'
264267

265268
test_expect_success 'ls-remote with filtered symref (refname)' '

0 commit comments

Comments
 (0)