git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 5/6] mktag tests: test for-each-ref

From
Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Date
Jun 14, 2021, 17:28 UTC
Message-ID
<patch-5.6-8a626fc63a1-20210614T172422Z-avarab@gmail.com>
In-Reply-To
<cover-0.6-00000000000-20210614T172422Z-avarab@gmail.com>

Add a "for-each-ref" for all the mktag tests. This test would have caught the segfault which was fixed in c6854508808 (ref-filter: fix NULL check for parse object failure, 2021-04-01). Let's make sure we test that code more exhaustively.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
---
 t/t3800-mktag.sh | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/t/t3800-mktag.sh b/t/t3800-mktag.sh
index f5a51d11f81..7d0ad3c8e62 100755
--- a/t/t3800-mktag.sh
+++ b/t/t3800-mktag.sh
@@ -50,7 +50,7 @@ check_verify_failure () {
 		rm -rf bad-tag &&
 
 		git init --bare bad-tag &&
-		git -C bad-tag hash-object -t tag -w --stdin --literally <tag.sig
+		bad_tag=$(git -C bad-tag hash-object -t tag -w --stdin --literally <tag.sig)
 	'
 
 	test_expect_success "hash-object & fsck unreachable: $subject" '
@@ -75,6 +75,16 @@ check_verify_failure () {
 		# will always fail.
 		test_must_fail git -C bad-tag fsck
 	'
+
+	test_expect_success "for-each-ref: $subject" '
+		echo "$bad_tag" >"bad-tag/$tag_ref" &&
+
+		printf "%s tag\t%s\n" "$bad_tag" "$tag_ref" >expected &&
+		git -C bad-tag for-each-ref "$tag_ref" >actual &&
+		test_cmp expected actual &&
+
+		test_must_fail git -C bad-tag for-each-ref --format="%(*objectname)"
+	'
 }
 
 test_expect_mktag_success() {
-- 
2.32.0.555.g0268d380f7b
Previous: Ævar Arnfjörð BjarmasonNext: Junio C Hamano
Message 9 of 17 in “mktag tests: test more exhaustively”
  1. 0/6 mktag tests: test more exhaustivelyÆvar Arnfjörð Bjarmason, Jun 14, 2021
  2. 1/6 mktag tests: parse out options in helperÆvar Arnfjörð Bjarmason, Jun 14, 2021
  3. 4/6 mktag tests: test update-ref and reachable fsckÆvar Arnfjörð Bjarmason, Jun 14, 2021
  4. 3/6 mktag tests: test hash-object --literally and unreachable fsckÆvar Arnfjörð Bjarmason, Jun 14, 2021
  5. Andrei RybakJun 15, 2021
  6. Ævar Arnfjörð BjarmasonJun 15, 2021
  7. 2/6 mktag tests: invert --no-strict testÆvar Arnfjörð Bjarmason, Jun 14, 2021
  8. 6/6 mktag tests: test fast-exportÆvar Arnfjörð Bjarmason, Jun 14, 2021
  9. 5/6 mktag tests: test for-each-refÆvar Arnfjörð Bjarmason, Jun 14, 2021
  10. Junio C HamanoJun 15, 2021
  11. 0/6 mktag tests: test more exhaustivelyÆvar Arnfjörð Bjarmason, Jun 17, 2021
  12. 1/6 mktag tests: parse out options in helperÆvar Arnfjörð Bjarmason, Jun 17, 2021
  13. 2/6 mktag tests: invert --no-strict testÆvar Arnfjörð Bjarmason, Jun 17, 2021
  14. 3/6 mktag tests: test hash-object --literally and unreachable fsckÆvar Arnfjörð Bjarmason, Jun 17, 2021
  15. 5/6 mktag tests: test for-each-refÆvar Arnfjörð Bjarmason, Jun 17, 2021
  16. 4/6 mktag tests: test update-ref and reachable fsckÆvar Arnfjörð Bjarmason, Jun 17, 2021
  17. 6/6 mktag tests: test fast-exportÆvar Arnfjörð Bjarmason, Jun 17, 2021

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.