@@ -315,6 +315,33 @@ test_expect_success '%(deltabase) reports packed delta bases' '
}
'
+missing_oid=$(test_oid deadbeef)
+test_expect_success 'error on type of missing object' '
+ cat >expect.err <<-\EOF &&
+ fatal: git cat-file: could not get object info
+ EOF
+ test_must_fail git cat-file -t $missing_oid >out 2>err &&
+ test_must_be_empty out &&
+ test_cmp expect.err err &&
+
+ test_must_fail git cat-file -t --allow-unknown-type $missing_oid >out 2>err &&
+ test_must_be_empty out &&
+ test_cmp expect.err err
+'
+
+test_expect_success 'error on size of missing object' '
+ cat >expect.err <<-\EOF &&
+ fatal: git cat-file: could not get object info
+ EOF
+ test_must_fail git cat-file -s $missing_oid >out 2>err &&
+ test_must_be_empty out &&
+ test_cmp expect.err err &&
+
+ test_must_fail git cat-file -s --allow-unknown-type $missing_oid >out 2>err &&
+ test_must_be_empty out &&
+ test_cmp expect.err err
+'
+
bogus_type="bogus"
bogus_content="bogus"
bogus_size=$(strlen "$bogus_content")
Test for what happens when the -t and -s flags are asked to operate on a missing object, this extends tests added in 3e370f9faf0 (t1006: add tests for git cat-file --allow-unknown-type, 2015-05-03). The -t and -s flags are the only ones that can be combined with --allow-unknown-type, so let's test with and without that flag. Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> --- t/t1006-cat-file.sh | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+)