Skip to content

Commit c471623

Browse files
peffgitster
authored andcommitted
t5512: test "ls-remote --heads --symref" filtering with v0 and v2
We have two overlapping tests for checking the behavior of "ls-remote --symref" when filtering output. The first test checks that using "--heads" will omit the symref for HEAD (since we don't print anything about HEAD at all), but still prints other symrefs. This has been marked as expecting failure since it was added in 99c08d4 (ls-remote: add support for showing symrefs, 2016-01-19). That's because back then, we only had the v0 protocol, and it only reported on the HEAD symref, not others. But these days we have v2, which does exactly what the test wants. It would even have started unexpectedly passing when we switched to v2 by default, except that b2f73b7 (t5512: compensate for v0 only sending HEAD symrefs, 2019-02-25) over-zealously marked it to run only in v0 mode. So let's run it with both protocol versions, and adjust the expected output for each. It passes in v2 without modification. In v0 mode, we'll drop the extra symref, but this is still testing something useful: it ensures that we do omit HEAD. The test after this checks "--heads" again, this time using the expected v0 output. That's now redundant. It also checks that limiting with a pattern like "refs/heads/*" works similarly, but that's redundant with a test earlier in the script which limits by HEAD (again, back then the "HEAD" test was less interesting because there were no other symrefs to omit, but in a modern v2 world, there are). So we can just delete that second test entirely. Signed-off-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent d6747ad commit c471623

File tree

1 file changed

+7
-19
lines changed

1 file changed

+7
-19
lines changed

t/t5512-ls-remote.sh

Lines changed: 7 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -275,30 +275,18 @@ test_expect_success 'ls-remote with filtered symref (refname)' '
275275
test_cmp expect actual
276276
'
277277

278-
test_expect_failure 'ls-remote with filtered symref (--heads)' '
278+
test_expect_success 'ls-remote with filtered symref (--heads)' '
279279
git symbolic-ref refs/heads/foo refs/tags/mark &&
280-
cat >expect <<-EOF &&
280+
cat >expect.v2 <<-EOF &&
281281
ref: refs/tags/mark refs/heads/foo
282282
$rev refs/heads/foo
283283
$rev refs/heads/main
284284
EOF
285-
# Protocol v2 supports sending symrefs for refs other than HEAD, so use
286-
# protocol v0 here.
287-
GIT_TEST_PROTOCOL_VERSION=0 git ls-remote --symref --heads . >actual &&
288-
test_cmp expect actual
289-
'
290-
291-
test_expect_success 'ls-remote --symref omits filtered-out matches' '
292-
cat >expect <<-EOF &&
293-
$rev refs/heads/foo
294-
$rev refs/heads/main
295-
EOF
296-
# Protocol v2 supports sending symrefs for refs other than HEAD, so use
297-
# protocol v0 here.
298-
GIT_TEST_PROTOCOL_VERSION=0 git ls-remote --symref --heads . >actual &&
299-
test_cmp expect actual &&
300-
GIT_TEST_PROTOCOL_VERSION=0 git ls-remote --symref . "refs/heads/*" >actual &&
301-
test_cmp expect actual
285+
grep -v "^ref: refs/tags/" <expect.v2 >expect.v0 &&
286+
git -c protocol.version=0 ls-remote --symref --heads . >actual.v0 &&
287+
test_cmp expect.v0 actual.v0 &&
288+
git -c protocol.version=2 ls-remote --symref --heads . >actual.v2 &&
289+
test_cmp expect.v2 actual.v2
302290
'
303291

304292
test_expect_success 'indicate no refs in v0 standards-compliant empty remote' '

0 commit comments

Comments
 (0)