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

[PATCH 10/10] t6301: write invalid object ID via `test-tool ref-store`

From
Patrick Steinhardt <ps@pks.im>
Date
Nov 29, 2023, 07:25 UTC
Message-ID
<281d9a719d39c03572de53bce5388acc7236b274.1701242407.git.ps@pks.im>
In-Reply-To
<cover.1701242407.git.ps@pks.im>

One of the tests in t6301 verifies that the reference backend correctly warns about the case where a reference points to a non-existent object. This is done by writing the object ID into the loose reference directly, which is quite intimate with how the files backend works.

Refactor the code to instead use `test-tool ref-store` to write the reference, which is backend-agnostic.

There are two more tests in this file which write loose files directly, as well. But both of them are indeed quite specific to the loose files backend and cannot be easily ported to other backends. We thus mark them as requiring the REFFILES prerequisite.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
---
 t/t6301-for-each-ref-errors.sh | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)
diff --git a/t/t6301-for-each-ref-errors.sh b/t/t6301-for-each-ref-errors.sh
index 2667dd13fe..83b8a19d94 100755
--- a/t/t6301-for-each-ref-errors.sh
+++ b/t/t6301-for-each-ref-errors.sh
@@ -15,7 +15,7 @@ test_expect_success setup '
 	git for-each-ref --format="%(objectname) %(refname)" >brief-list
 '
 
-test_expect_success 'Broken refs are reported correctly' '
+test_expect_success REFFILES 'Broken refs are reported correctly' '
 	r=refs/heads/bogus &&
 	: >.git/$r &&
 	test_when_finished "rm -f .git/$r" &&
@@ -25,7 +25,7 @@ test_expect_success 'Broken refs are reported correctly' '
 	test_cmp broken-err err
 '
 
-test_expect_success 'NULL_SHA1 refs are reported correctly' '
+test_expect_success REFFILES 'NULL_SHA1 refs are reported correctly' '
 	r=refs/heads/zeros &&
 	echo $ZEROS >.git/$r &&
 	test_when_finished "rm -f .git/$r" &&
@@ -39,15 +39,14 @@ test_expect_success 'NULL_SHA1 refs are reported correctly' '
 '
 
 test_expect_success 'Missing objects are reported correctly' '
-	r=refs/heads/missing &&
-	echo $MISSING >.git/$r &&
-	test_when_finished "rm -f .git/$r" &&
-	echo "fatal: missing object $MISSING for $r" >missing-err &&
+	test_when_finished "git update-ref -d refs/heads/missing" &&
+	test-tool ref-store main update-ref msg refs/heads/missing "$MISSING" "$ZERO_OID" REF_SKIP_OID_VERIFICATION &&
+	echo "fatal: missing object $MISSING for refs/heads/missing" >missing-err &&
 	test_must_fail git for-each-ref 2>err &&
 	test_cmp missing-err err &&
 	(
 		cat brief-list &&
-		echo "$MISSING $r"
+		echo "$MISSING refs/heads/missing"
 	) | sort -k 2 >missing-brief-expected &&
 	git for-each-ref --format="%(objectname) %(refname)" >brief-out 2>brief-err &&
 	test_cmp missing-brief-expected brief-out &&
-- 
2.43.0
Previous: Taylor BlauNext: Taylor Blau
Message 14 of 16 in “t: more compatibility fixes with reftables”
  1. 00/10 t: more compatibility fixes with reftablesPatrick Steinhardt, Nov 29, 2023
  2. 01/10 t0410: mark tests to require the reffiles backendPatrick Steinhardt, Nov 29, 2023
  3. Taylor BlauNov 29, 2023
  4. 02/10 t1400: split up generic reflog tests from the reffile-specific onesPatrick Steinhardt, Nov 29, 2023
  5. 03/10 t1401: stop treating FETCH_HEAD as real referencePatrick Steinhardt, Nov 29, 2023
  6. 04/10 t1410: use test-tool to create empty reflogPatrick Steinhardt, Nov 29, 2023
  7. 05/10 t1417: make `reflog --updateref` tests backend agnosticPatrick Steinhardt, Nov 29, 2023
  8. 06/10 t3310: stop checking for reference existence via `test -f`Patrick Steinhardt, Nov 29, 2023
  9. 07/10 t4013: simplify magic parsing and drop "failure"Patrick Steinhardt, Nov 29, 2023
  10. 08/10 t5401: speed up creation of many branchesPatrick Steinhardt, Nov 29, 2023
  11. Taylor BlauNov 29, 2023
  12. 09/10 t5551: stop writing packed-refs directlyPatrick Steinhardt, Nov 29, 2023
  13. Taylor BlauNov 29, 2023
  14. 10/10 t6301: write invalid object ID via `test-tool ref-store`Patrick Steinhardt, Nov 29, 2023
  15. Taylor BlauNov 29, 2023
  16. Patrick SteinhardtNov 30, 2023

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.