]> git.ipfire.org Git - thirdparty/git.git/commitdiff
fsck tests: add test for fsck-ing an unknown type
authorÆvar Arnfjörð Bjarmason <avarab@gmail.com>
Fri, 1 Oct 2021 09:16:37 +0000 (11:16 +0200)
committerJunio C Hamano <gitster@pobox.com>
Fri, 1 Oct 2021 22:05:59 +0000 (15:05 -0700)
Fix a blindspot in the fsck tests by checking what we do when we
encounter an unknown "garbage" type produced with hash-object's
--literally option.

This behavior needs to be improved, which'll be done in subsequent
patches, but for now let's test for the current behavior.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
t/t1450-fsck.sh

index 5071ac63a5b51b89c973456211ce3aaac3587553..beb233e91b1f9ee6cd6aadd2c1054ae8c5d1b5ff 100755 (executable)
@@ -865,4 +865,20 @@ test_expect_success 'detect corrupt index file in fsck' '
        test_i18ngrep "bad index file" errors
 '
 
+test_expect_success 'fsck hard errors on an invalid object type' '
+       git init --bare garbage-type &&
+       (
+               cd garbage-type &&
+
+               git hash-object --stdin -w -t garbage --literally </dev/null &&
+
+               cat >err.expect <<-\EOF &&
+               fatal: invalid object type
+               EOF
+               test_must_fail git fsck >out 2>err &&
+               test_cmp err.expect err &&
+               test_must_be_empty out
+       )
+'
+
 test_done