Add a test of how "cat-file" behaves when given a bogus type in its "git cat-file <TYPE> <OBJECT>" mode. There were existing tests (just below this one) for "-t bogus" or "--allow-unknown-type" modes, but none for the switch-less mode. This test is similar to the one that exists for "git hash-object" already, see b7994af0f92 (type_from_string_gently: make sure length matches, 2015-04-17). Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@xxxxxxxxx> --- t/t1006-cat-file.sh | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/t/t1006-cat-file.sh b/t/t1006-cat-file.sh index 5d2dc99b74..908797dcae 100755 --- a/t/t1006-cat-file.sh +++ b/t/t1006-cat-file.sh @@ -315,6 +315,22 @@ test_expect_success '%(deltabase) reports packed delta bases' ' } ' +test_expect_success 'cat-file complains about bogus type name' ' + test_must_fail git cat-file co HEAD >out 2>err && + test_must_be_empty out && + cat >expected <<-\EOF && + fatal: invalid object type "co" + EOF + test_cmp expected err && + + test_must_fail git cat-file bogus HEAD >out 2>err && + test_must_be_empty out && + cat >expected <<-\EOF && + fatal: invalid object type "bogus" + EOF + test_cmp expected err +' + bogus_type="bogus" bogus_content="bogus" bogus_size=$(strlen "$bogus_content") -- 2.31.1.723.ga5d7868e4a