Skip to content

Commit 866a1b9

Browse files
pks-tgitster
authored andcommitted
t6301: write invalid object ID via test-tool ref-store
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 2e4afda commit 866a1b9

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

t/t6301-for-each-ref-errors.sh

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ test_expect_success setup '
1515
git for-each-ref --format="%(objectname) %(refname)" >brief-list
1616
'
1717

18-
test_expect_success 'Broken refs are reported correctly' '
18+
test_expect_success REFFILES 'Broken refs are reported correctly' '
1919
r=refs/heads/bogus &&
2020
: >.git/$r &&
2121
test_when_finished "rm -f .git/$r" &&
@@ -25,7 +25,7 @@ test_expect_success 'Broken refs are reported correctly' '
2525
test_cmp broken-err err
2626
'
2727

28-
test_expect_success 'NULL_SHA1 refs are reported correctly' '
28+
test_expect_success REFFILES 'NULL_SHA1 refs are reported correctly' '
2929
r=refs/heads/zeros &&
3030
echo $ZEROS >.git/$r &&
3131
test_when_finished "rm -f .git/$r" &&
@@ -39,15 +39,14 @@ test_expect_success 'NULL_SHA1 refs are reported correctly' '
3939
'
4040

4141
test_expect_success 'Missing objects are reported correctly' '
42-
r=refs/heads/missing &&
43-
echo $MISSING >.git/$r &&
44-
test_when_finished "rm -f .git/$r" &&
45-
echo "fatal: missing object $MISSING for $r" >missing-err &&
42+
test_when_finished "git update-ref -d refs/heads/missing" &&
43+
test-tool ref-store main update-ref msg refs/heads/missing "$MISSING" "$ZERO_OID" REF_SKIP_OID_VERIFICATION &&
44+
echo "fatal: missing object $MISSING for refs/heads/missing" >missing-err &&
4645
test_must_fail git for-each-ref 2>err &&
4746
test_cmp missing-err err &&
4847
(
4948
cat brief-list &&
50-
echo "$MISSING $r"
49+
echo "$MISSING refs/heads/missing"
5150
) | sort -k 2 >missing-brief-expected &&
5251
git for-each-ref --format="%(objectname) %(refname)" >brief-out 2>brief-err &&
5352
test_cmp missing-brief-expected brief-out &&

0 commit comments

Comments
 (0)